setting a variable based on dynamic input?

Hi there

I have a frameset with the main content on the left, and the table of contents on the right. When the user logs into the main page, a variable "isSearch" is set to true ( session.setAttribute("isSearch", "true") ). However, I want the variable to be set to false whenever the user clicks on certain links on my table of contents frame. Is there anyway to do this within JSP ?

Here is kinda what I want to do:

onClick=" <% session.setAttribute("isSearch", "false"); %>"

The onClick value will be parsed and executed when the JSP has been compiled into a servlet, so there is no dynamic aspect here.

I know Java and JavaScript can communicate with each via LiveConnect (using Netscape), but from what I have read, it only works if your Java program is an applet, which is not the case here.

Any ideas?

Aaron

[879 byte] By [arcooper] at [2007-9-26 3:37:38]
# 1

You're trying to use server-side code on the client side. Not possible. You need to explicitely send the parameter to the server every time you want it changed (i.e. on every link that depends upon it). It is not possible to use JSP to update a session variable without sending a HTTP request to the server.

I question whether the variable should be in the session at all - it sounds very much like individual requests are dependent upon it individually - why not make it a request parameter?

Just change your links:

href='<Whatever href curently is>?isSearch=flase'

Then use request.getParameter in your servlet or JSP that you are linking to.

mattbunch at 2007-6-29 12:10:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi Mattthanks for the reply. Yes, I was thinking about adding them to the request object. I'm going to give it a try.Cheers!Aaron
arcooper at 2007-6-29 12:10:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Did it help? Hows about those Duke DOolars if it did? Hint Hint..
mattbunch at 2007-6-29 12:10:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hi Matt

I am trying with the request object, but both request.setAttribute() and <jsp:forward> tags are not sending the values to my main page (which consists of 3 frames) . I have posted another post called "setting request parameters?". I will give you the Duke Dollars for your help, but if you can help on this simple problem, I'll give you the 4 I have for that post as well ;)

Cheers

Aaron

arcooper at 2007-6-29 12:10:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Hi Aaron,Didn't mean to be pushy, but hey, they just hang around doing nothing if you don't give 'em to somebody - seems like a bit of a waste.On my way to your next post now....Cheers,Matt
mattbunch at 2007-6-29 12:10:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...