Hi:
I can successfully get and email static HTML message from any http web site .
I use method
openstream()
to connect to URL.
I try to use the same code to run a jsp use and try to use it's output as the
content of an email message.
Here I set the scope as "request":
<jsp:useBean id="mybean" scope="request" class="emailtools.EmailBean" />
When I turn on the server, it seems the server can not find the the site and
just endlessly looking for the URL! But when I rewrite the URL to other web site,
it works very well.
Is it not suitable in this case to use method "openstream()" to connect to URL?
So what's the difference between "HttpURLConnection" and "openstream()"?
Any one can help me?
Thanks.
My codes are something like that.
**************************
package emailtools
import java.io.*;
import java.net.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class EmailBean{
.......
.......
private Session session;
private MimeMessage msg;
private URL url;
private BufferedReader in;
public EmailBean() throws MalformedURLException, IOException {
url= new URL("http://127.0.0.1:8080/examples/jsp/emailtools/test.jsp");
//can not find it?
in= new BufferedReader(new InputStreamReader(url.openStream()));
//Problem???
.....
.....
private boolean messageHandle(){
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
session = Session.getDefaultInstance(props, null);
......
......
}
public void collectHtml(BufferedReader in, Message msg)
throws MessagingException, IOException {
String line;
StringBuffer sb = new StringBuffer();
..........
while ((line = in.readLine()) != null) {
sb.append(line);
...............
}
}
*****************************
===========================================================================
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