use this code in jsp
<%
URL url=new URL("http://www.yahoo.com.com);
BufferedReader rd=new BufferedReader(new
InputStreamReader(url.openStream()));
String s="";
while( (s=rd.readLine())!= null)
out.println(s)
%>
URL url=new URL("http://www.theurl.com);
BufferedReader rd=new BufferedReader(new
InputStreamReader(url.openStream()));
String s=rd.readLine();
-----Original Message-----
From: Yunyun Cai [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 26, 2000 12:24 PM
To: [EMAIL PROTECTED]
Subject: Re: absolute url
Hi, Phil,
Thanks for your reply.
Actually I am asking how to include information from a document given its
absolute url.
It seems to me that JSP's include tag only works with the relative url?
What I want to ask is how to make the Yahoo page
embedded right in the middle of the other page?
Thanks,
Yunyun
-----Original Message-----
From: Phil Campbell [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 26, 2000 1:21 PM
To: [EMAIL PROTECTED]
Subject: Re: absolute url
> [is] there... a simple way to include an absolute url
> (eg. http://www.yahoo.com) in the jsp file?
Yunyun:
Not sure what you are asking. Are you asking how to include information
from
a document given its absolute url; or are you asking how to create an href
link to an absolute url?
>From your example (yahoo), I assume you are asking how to include an href
link. (The alternative is accomplished through JSP's include tag).
Here are a couple of ways jsp may return an href to a browser:
1. The easy, static way is just place your html code outside the <% %>
jsp tags, i.e.:
/* close your scriptlet block */
%>
<p>Visit Yahoo by clicking here:
<a href='http://www.yahoo.com'>Visit Yahoo!</a></p>
<p>Or visit many other fine search engines blablabla... </p>
<%
/* continue your scriptlet processing...
* anything entered outside jsp tags is passed to the browser, without
processing.
* if it is a valid html code, the browser will process it, creating
the
example href link.
*/
2. A dynamic way may be done as something like this:
<% // our scriptlet will process and return our html href tag
String tmp ;
// the calling html page passes an option to the jsp as a
variable,
// such as http://mySite.com/myJSP.jsp?ref=yahoo
String ref = request.getParameter("ref") ;
// then test the variable...
if ref.equals( "yahoo" ) {
tmp = "<p>Visit Yahoo by clicking here: " +
"<a href='http://www.yahoo.com'>Visit
Yahoo!</a></p>" ;
out.println( tmp ) ;
}
else {
// do something else...
}
%>
Of course, you also can mix the logic of these options, eliminating, for
example, the need for out.println().
Hopefully this answers your question. Please forgive me if I misunderstood
it.
Phil
-----Original Message-----
From: Yunyun Cai <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Friday, May 26, 2000 10:31 AM
Subject: absolute url
>Hi,
>I am wondering if there is a simple way to include an absolute url (eg.
>http://www.yahoo.com)in the jsp file?
>
>Thanks in advance,
>Yunyun
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets