aspose file tools*
The moose likes Servlets and the fly likes How to pass different request Parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to pass different request Parameters" Watch "How to pass different request Parameters" New topic
Author

How to pass different request Parameters

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
Hi Guys,
I have different buttons in my HTML page which calls different JSP's. How can I pass the request parameters with these submit button so that my intermediate servlet knows which JSP is requested. It would be great if somebody could tell me how can my servlet know which button was pressed in my HTML page.
Thanks
Neha
Dave Soto
Ranch Hand

Joined: Sep 15, 2001
Posts: 55
I'm not sure if I understand what you're asking, but it sounds as if you've got a servlet that responds to requests with some HTML, and in that HTML you have some FORMs that list as their actions different JSP pages. If that is the case, then your servlet is not involved in the processing of those JSP pages, and will not know anything about them.
As to how you can pass parameters, well in the ACTION="..." section of your form tags, you can do ACTION="myPage.jsp?param1=value1¶m2=value2". But for some reason I don't think that's what you're asking.
I think you might want to read into a pattern called Front Controller. You can find information about it at Sun's Java Center.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Your <form> should look something like this:

Then, in your servlet, request.getParameter("jspSelector") will return the value (jsp1, jsp2, or jsp3) of the button that was pressed.
------------------
Miftah Khan
- Sun Certified Programmer for the Java� 2 Platform
- Sun Certified Web Component Developer for the Java� 2 Platform, Enterprise Edition
[This message has been edited by Miftah Khan (edited September 24, 2001).]
Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
Thanks Guys,
Miftah is there a way I can show something else on the button. I want the request.parameter value different from what the Button dispalys.
Neha
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I want the request.parameter value different from what the Button dispalys.
I don't believe this is possible. I checked the HTML 4.01 specification.
------------------
Miftah Khan
- Sun Certified Programmer for the Java� 2 Platform
- Sun Certified Web Component Developer for the Java� 2 Platform, Enterprise Edition
shashank bapat
Ranch Hand

Joined: Jul 11, 2001
Posts: 69
Originally posted by Miftah Khan:
I want the request.parameter value different from what the Button dispalys.
I don't believe this is possible. I checked the HTML 4.01 specification.

That Sucks
I guess there is a W3C group working to change that.

-Shashank<BR>MS(CS),BS(CS),SCJP2
Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
That's really amazing, something like this not possible, How about if I want to put a .gif image on the button.
Neha
shashank bapat
Ranch Hand

Joined: Jul 11, 2001
Posts: 69
Originally posted by Neha Sharma:
How about if I want to put a .gif image on the button.
Neha

I think that is possible with beans or activex. not sure of exact details though. Worth looking at Object and EMBD tags.
Shashank
Dave Soto
Ranch Hand

Joined: Sep 15, 2001
Posts: 55
There is typically no need to have a different value passed than what is displayed on the button... Here's why:
If you have three buttons, and you want them to display
Reply
Reply with Quote
New Thread

then just set them up like this:

Then, you just test for those values in your servlet, instead of testing for jsp1, jsp2, and jsp3.
Good luck!
P.S. In light of this, you may want to withhold your flames to the W3C (at least for now).
[This message has been edited by Dave Soto (edited September 25, 2001).]
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
you can try calling javascript submit() function on click of your button, just pass different param in the submit() function for each button...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass different request Parameters