Forums Register Login

How to pass different request Parameters

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
That's really amazing, something like this not possible, How about if I want to put a .gif image on the button.
Neha
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
you can try calling javascript submit() function on click of your button, just pass different param in the submit() function for each button...
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1653 times.
Similar Threads
calling doGet(), doPost() on html page load
doGet() but I don'tGet()
Getting the name of the requesting page
Servlet
Is it possible to return an image with a web service ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:56:12.