Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

Getting parameters from doGet()

 
Carol Murphy
village idiot
Bartender
Posts: 1202
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is sort of a duplicate post, I asked a similar question in the HTML forum, but it occured to me maybe my problem is related more to servlets than HTML.
I'm working on a CattleDrive assignment. I'm trying to send a parameter along with the url in an href link to a servlet. The servlet will look at the parameter and decide which jsp page to forward the request to.
I got this whole thing working using forms, because I know how to send and read parameters using a form, but I have to figure out how to do it using a link only, which means a get request with no form for submitting data. No button involved. Only a link.
I tried appending the name/value pair on to the url in the link, but my servlet still can't read the parameter using getParameter(), getParameterValue(), or getAttribute(), or getString( key ) for that matter. (A method in the com.javaranch.common package.)
Is there a special way to access parameters in the querystring that I am unable to find any info on? All the stuff I'm reading seems to be for getting data from forms.
I guess I need to figure out the following:
A) How to get data into the querystring without using an input button.
B) How to retrieve said data in my servlet.

Any thoughts?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Regardless of how the request parameters get to the servlet, the getParameter() family of methods is used. So the problemis most likely in the building of your URL.

I'll closed this topic and we'll focus on the HTML forum post.
 
    Bookmark Topic Watch Topic
  • New Topic