views:

159

answers:

1

Hi there, Firstly, I have done my research and already know that JavaScript = client JSPs = server side. I don't want to waste your time.

My situation is that I want to execute JSP code from an event (not from a HTML form).

I have a HTML link (<a href="...">XXX</a>), which is NOT within <form> tags; it just an ordinary HTML link. Through Javascript, I will be able to get the href value and store it in a hidden input field. Instantly after this, I want to execute request.getAttribute("...") and pass the parameter between JSP pages.

I do now know how to do the latter part (i.e. getting the request.getAttribute code to instantly proceed after the Javascript code has executed.

Can anyone advise?

Thankyou, Lucas

+1  A: 

You can't run JSP code like this.

JSP code, as you said is run on the server side, so you can't really trigger it from the web browser.

If you are just trying to pass a parameter between JSP pages, you can add the parameter to the queryString of the URL when you call the second JSP, and within it use request.getAttribute().

Remember, JSP code is executed before the page is sent to the browser.

I hope this helps.

Chrisb