File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Passing values in URL to Java Web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing values in URL to Java Web application" Watch "Passing values in URL to Java Web application" New topic
Author

Passing values in URL to Java Web application

Alix Sye
Greenhorn

Joined: Jun 07, 2006
Posts: 17
Hello All

I need help regarding how to pass values in a url to my java application.
For example my application is www.xyz.com and some one try to send telephone info with that url like www.xyz.com/tel=6463339999. How can i receive that value in my servlet or index.jsp page. I do not know how to retrieve a value send via url directly to my website. Please guide me. Please also tell me what is Http get, some body told me i can use http get to retrieve values sent directlyin url...... thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Sounds like you haven't done any servlet programming yet. It'd be best to find yourself a good book or tutorial as these are very basic questions.

The URL you showed was not well formed; the ? character was missing from the query string.

If it were well-formed, you would be able to retrieve the values of the query parameters with methods defined on HttpServletRequest.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alix Sye
Greenhorn

Joined: Jun 07, 2006
Posts: 17
i know how to retrieve parm values when sent via form using post to servlet using getParameter. My questions is if some one else send a parameter attached to my website url then how i retrieve that value. because when i type www.xyz.com it goes to the index.jsp page. I have MVC design on my site so all requests go thru a single servlet. MY website is build in j2ee using jsp and servlet. can some body give me a sample code how to retrieve values if sent in url form some body else...thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

getParameter can be used for both form parameters and querystring parameters.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Badri Sarma
Ranch Hand

Joined: Apr 01, 2003
Posts: 72
Hi,

We can use the following method gerParameterNames(), this will return you the enumeration of the names that we have in url.


Thanks<br />Badri
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Others have already answered. But, I think the reason you cannot get the parameters is that:

www.xyz.com/tel=6463339999. Is not referring to any servlet, but to your webapp root, and since it looks like you have index.jsp as a welcome-file, So references that specify your webapp root without a resource are taken to index.jsp. Unless the user specifies the path to the servlet that can read the parameters, there is no way you are doing to be able to read those parameters.


Originally posted by Alix Sye:
i know how to retrieve parm values when sent via form using post to servlet using getParameter. My questions is if some one else send a parameter attached to my website url then how i retrieve that value. because when i type www.xyz.com it goes to the index.jsp page. I have MVC design on my site so all requests go thru a single servlet. MY website is build in j2ee using jsp and servlet. can some body give me a sample code how to retrieve values if sent in url form some body else...thanks

[ June 12, 2006: Message edited by: Bosun Bello ]

Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Awsom Kyd
Greenhorn

Joined: Jun 22, 2006
Posts: 1
I know this post is old but if unresolve, this might help
www.xyz.com?tel=6463339999.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Awesom Kyd",
Welcome to the Ranch!

We're a friendly bunch, but we take our display names very seriously.

Display names must be two words: your first name, a space, then your last name, and fictitious names are not allowed.

Please edit your profile and correct your display name, since accounts with invalid display names get deleted.

thanks,
Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing values in URL to Java Web application