views:

38

answers:

1

So, I am trying to use JSP to create a set of webpages. I want to link two pages so that if the user clicks a button in one page, it will trigger an event in the other page. Is there an efficient way to do this?

I was taking a look at creating cookies and/or sessions. Any suggestions on these two methods? Thanks

Edit: The second page that is affected by the button click on the first page should already be open. I do not want a new tab to come up when I click the button on the first page. If the responding page is not open, nothing should happen.

+1  A: 

If it are two independent pages, your best bet is to use either HTTP push (read on about "Comet") or Ajax poll. I only question why you were explicitly asking for linking two pages (and not three or more), so those pages must be somehow related to each other. If the second page is actually opened by for example Javascript window.open(), then you can make use of the window instance to access the second page and the window.opener property to access the parent page from the second page.

JSP as being a view technology can't do much for you here since it is just there to generate and send all the necessary HTML/CSS/JS, if not with help of taglibs and/or EL to access the "backend" Java code.

BalusC