aspose file tools*
The moose likes Servlets and the fly likes Loading HTML into a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading HTML into a Servlet" Watch "Loading HTML into a Servlet" New topic
Author

Loading HTML into a Servlet

Richard Scothern
Ranch Hand

Joined: May 25, 2001
Posts: 83
Hi,
I am writing a servlet that will parse HTML code. I would like the servlet to retrieve an HTML page that is given as a parameter in the GET request. Does anyone know the easiest way to do this.
Thanks,
Richard
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
How about opening the file using the File class to represent it, and then reading it with a BufferedReader and then parsing it?


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Kris Nelson
Ranch Hand

Joined: Nov 04, 2001
Posts: 35
Although I could be wrong, but I thought the java.io.File class handled files on a local machine and the java.net.URL class handled files across a network (i.e. Internet). I have used the java.io.File class in JavaServer Pages and Servlets for files on my server only, but I don't think it worked when I tried to instaniate them as follows:
File f = new File( "http://www.webnelly.com/includes/index_main.htm" );
I thought which class you used was dependant on whose files you were looking at (which wasn't specified in the orignal post). Please correct me if I've said anything in error (which has been known to happen).

------------------
WebNelly.com
Java/XML Web Development
Check it out!
http://www.webnelly.com


WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>
Richard Scothern
Ranch Hand

Joined: May 25, 2001
Posts: 83
Actually I figured out an easier way, by using the URLConnection class.
thanks anyway
richard
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
I didn't know where the HTML file was; in the client or in the server?
It helps to know...
 
wood burning stoves
 
subject: Loading HTML into a Servlet