• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Copying html web page to servlet

 
Greenhorn
Posts: 13
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 6619
1253
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below line no 40,
put "out.println(in.readLine());"
Line no 44 to 51 is not required .
This will work seamlessly.
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic