EpsilonVector
EpsilonVector

Reputation: 4053

Make a link pass extra information to a JSP

I want to do something like this:

<a href="myJSPFile" onClick="request.setAttribute("special case")"> click here </a>

Any way to achieve this?

Upvotes: 0

Views: 490

Answers (2)

Dean
Dean

Reputation: 8998

You could put all information in a session which then would be better if the browser closes unexpectedly. Some sample code:
In the first page when the user clicks.

session.setAttribute("nameOfAttribute", informationForAttribute);

To retrieve the information:

session.getAttribute("nameOfAttribute")

This would then mean you can have a cleaner URL as you don't have to place query strings in the URL.

Here is a useful link on sessions.

Upvotes: 0

Chris
Chris

Reputation: 4471

Use the querystring.

<a href="myJSPFile?specialCase=imSpecial">click here</a>

Then read it with

request.getParameter("specialCase");

Upvotes: 4

Related Questions