Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

Getting parameters from doGet()  RSS feed

Carol Murphy
village idiot
Posts: 1211
  • 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
Posts: 66141
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!