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
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.
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).]
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
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
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).]