This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Passing parameters to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing parameters to the servlet" Watch "Passing parameters to the servlet" New topic
Author

Passing parameters to the servlet

paul Staniland
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Before when using the dreaded invoker servlet it was possible to pass the servlet the value of an ever-changing productID by doing something like this <a href="music/adminServlet?productID">

Is there a way to pass the servlet the value of productID by clicking on a hyperlink (generated dynamically) in my JSP page (that runs the servlet by way of servlet mapping through the web.xml file).

I know I could do it with servlet init params but I want the productID to be sent at runtime and not hardcode thousands of servlet mappings.
Also I know I could set a request or session attribute, but if you click on a hyperlink is it even possible to set one of these attributes?

Thanks,
Newbie in need of help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Whether the invoker is used or not is irrelevant to the ability pass parameters in the query string.

Did you try it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
paul Staniland
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Yes it's working now, thanks!

I did try that before but it didn't work (due to an incorrect web.xml file i now realise!)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing parameters to the servlet
 
Similar Threads
Setting a session attribute through JS
Make hyperlink that when clicked call a java method and display results
hyperlink-event using a servlet
Passing values between servlets
Passing parameter to jsp:include with c:set