Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting the source code of a url..  RSS feed

 
chakradhar , reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i will be obliged if u help me ....my problem is that i had created a html page in it i have a text feild ..in that feild if i enter a http ...and press the submit button ..it should display the source of the http in html format.....hope you could understand and replay..
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what you will have to do in the servlet.
1. Open a socket with the http server.
2. Get the HTML from that http in a String buffer.
3. Replace all '<' with &lt; , '>' with &gt;
4. Send it to the PrintWriter.
good luck
[This message has been edited by Deep Narsay (edited December 03, 2001).]
 
chakradhar , reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thank you for your valuable answer.hope it could help me .....bye
 
Raghavendra Holla
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Open URL connection depending on text box value.
2) Rewrite Get HTML file from getContent()
3) Send it to PrintWriter
4) Remember to setContentType to "text/plain"
hope that does your task!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!