aspose file tools*
The moose likes Servlets and the fly likes Copying html web page to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Copying html web page to servlet" Watch "Copying html web page to servlet" New topic
Author

Copying html web page to servlet

sriman roop
Greenhorn

Joined: Mar 02, 2013
Posts: 13

The servlet program below is to display the html webpage through servlet.
NewServlet.java


The servlet code above displaying null. Wats the error in the above code?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

The while loop in your code has already fetched out the whole content and reached the end of the page. Attempting to read another line after the end gives null. As a solution, remove that System.out.println line and append each inputLine to a StringBuilder. Each time the loop completes, your StringBuilder instance has the whole content.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Sai Prasad Sabeson
Greenhorn

Joined: Oct 10, 2011
Posts: 4
below line no 40,
put "out.println(in.readLine());"
Line no 44 to 51 is not required .
This will work seamlessly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Copying html web page to servlet
 
Similar Threads
HTTP Status 404 - Servlet is not available
Deploying My project in Jboss server
To run a simple servlet in Jboss 5.1.0
HTTP status 500-
what is called? service method or doGet method?