This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to pass parameter from dispatchto javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "how to pass parameter from dispatchto javascript" Watch "how to pass parameter from dispatchto javascript" New topic
Author

how to pass parameter from dispatchto javascript

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
In a servlet, I use dispatch and forward to go to another jsp, which contains some javascript code.
I want to pass a parameter in the dispatch and to be used by javascript.

I tried to set the parameter in the url, like blah.jsp?param=value, the forwarded jsp page url ends with blah.jsp, string after '?' is lost. Why would it be like this?

Then I tried to set parameter in the request. the forwarded jsp's javascript still cannot get the parameter value, since I'm not using java to get parameter. I need use javascript.

Can someone help me on this? What's the correct way to set it so that the target jsp page's javascript can access the parameter values.

Thanks.


SCJA, SCJP5.0, SCBCD, SCWCD
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

In Servlet:

In Jsp:
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to pass parameter from dispatchto javascript
 
Similar Threads
Re: using javascript in jsp's
FormBean - Hidden variable not set
getting data from java classes
Submitting a form from table item
passing value from one action to another