GeeCON Prague 2014*
The moose likes Servlets and the fly likes Getting parameters from doGet() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Getting parameters from doGet()

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
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

Joined: Jan 10, 2002
Posts: 61310
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Getting parameters from doGet()