• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading URL

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic