wood burning stoves 2.0*
The moose likes Java in General and the fly likes Reading URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading URL" Watch "Reading URL" New topic
Author

Reading URL

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
Hi,

I'm writing a program for my work and I have run into a bit of a problem. I need to read a URL to retrieve some parameters that I am passing in it. I know that I can read them with javascript, but I want to read the url with Java. Is there anyway of reading this string with Java 1.3? The server that our portal sits on only supports Java 1.3.

Thanks and regards,

Kevin
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Kevin,

It would help to know where the code is that you want to use to read a URL. Is it in a JSP file? in a servlet? When you say "read a URL", do you mean get the URL that was sent by a browser to your servlet? Or do you want to forward to another URL?

If the code you are writing is in a servlet or JSP, you can get it with a combination of request.getServerName(), request.getServletPath() and request.getQueryString() where request is a variable pointing to the HTTPServletRequest that was passed to you by the web container. getServerName gives you the first part of the url (myserver.com) and getServletPath() give you the second part (/myApplication/myServlet) and getQueryString() gives you the parameters passed (?parm1=abc&parm2=def)

If you simply wish to look at a parameter passed to you, the best way is to use request.getParamter("parm1") or request.getParameters("parm1") if you expect more than one value in "parm1". The first returns a String, and the second returns a String array.

Merrill
[ February 17, 2005: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
You're wanting to use server-side Java: J2EE
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html


You might start here to get an idea:
http://www.jsptut.com/Index.html
 
 
subject: Reading URL
 
Similar Threads
Reading UTF8 form input in a sevlet
Where are classes for GIF, JPEG, PNG?
comment problem
Percision problems with Double and Float numbers
Object Class