File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Getting parameters from doGet()

Carol Murphy
village idiot

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

Joined: Jan 10, 2002
Posts: 63858

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Getting parameters from doGet()
It's not a secret anymore!