• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to pass different request Parameters

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's really amazing, something like this not possible, How about if I want to put a .gif image on the button.
Neha
 
shashank shah
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can try calling javascript submit() function on click of your button, just pass different param in the submit() function for each button...
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic