Do you mean a web page you have access to ie on your server or some other
web page.
If the former read it in from a BufferedReader
If the latter you will need to make a URLConnection and read it in that way
eg:

                        InputStream is;
                        URLConnection uc;
                        StringBuffer sourceBuffer = new StringBuffer();
                        try{
                                URL userUrl = new URL(myURL);
                                uc = userUrl.openConnection();
                                is = userUrl.openStream();
                                BufferedReader in = new BufferedReader(new 
InputStreamReader(is));
                                String line = null;
                                while((line = in.readLine()) != null) {
                                        sourceBuffer.append(line);
                                }
                                is.close();
                        }
                        catch(Exception e) {}

You're not being very clear in your intention.

Mike W.

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Gehan
G.
Sent: 15 May 2002 20:16
To: [EMAIL PROTECTED]
Subject: HTML read question


 Hello, I'm new to this list, and to servlets. I've been java
programming for two years or so, and am just now getting in to
"web" programming....
My question is:
 Is there a way to read a web page in to a buffer for appending?
As an example if I wanted to append my name to the end of a page
when a user clicks a button. How can I do something like..

public void doPost (HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
PrintWriter             out;
response.setContentType("text/html");
out = response.getWriter();

// This obiouly won't work
StringBuffer webPage = readWholeWebpage();
webPage.append("<H1>Gehan Gehale</H1>");

//Print the webpage along with my added text
out.println(webPage);
out.close();
}

Any help on how to read a page in to a buffer, or string would
be much appreciated.

Gehan Gehale
[EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to