This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing values in URL to Java Web application

 
Alix Sye
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64194
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alix Sye
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getParameter can be used for both form parameters and querystring parameters.
 
Badri Sarma
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We can use the following method gerParameterNames(), this will return you the enumeration of the names that we have in url.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Awsom Kyd
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this post is old but if unresolve, this might help
www.xyz.com?tel=6463339999.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic