getURL está lhe retornando isto?
contato_email.jsp%3fnome%3dBruno+da+Gama%26email%3dbgamap%40gmail.com%26comentario%3dteste+de+e-mail
Você teria (de alguma forma) fazer com que getURL lhe retornasse algo como “http://blablabla/contato_email.jsp?nome=Bruno+da+Gama&email=gamap@gmail.com&comentario=teste+de+e-mail ”
Resolva esse problema primeiro, que o resto se resolve sozinho.
Olá pessoal eu estou tentando escrever um formulário de contato para um site utilizando jsp, javamail e etc. Porém eu desejo enviar um e-mail em html utilizando um método que carregue um jsp do meu site e o converte em uma string para enviar pelo javamail (já que ele aceita só strings).
porém estou tendo apenas essa exception:
[quote]type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.net.MalformedURLException: no protocol: contato_email.jsp%3fnome%3dBruno+da+Gama%26email%3dbgamap%40gmail.com %26comentario%3dteste+de+e-mail
java.net.URL.<init>(URL.java:567)
java.net.URL.<init>(URL.java:464)
java.net.URL.<init>(URL.java:413)
br.com.brg.w3.WebSource.getSource(WebSource.java:43)
org.apache.jsp.contato_jsp._jspService(org.apache.jsp.contato_jsp:131)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
[/quote]
já não sei mais o que pode ser feito.
o meu fonte está assim:
private String getURL() throws Exception {
//return org.w3.international.URLUTF8Encoder.encode( this.URL );
return URLEncoder.encode( this.URL,"ISO-8859-1" );
}
public String getSource() throws Exception {
URL urlObj = new URL( getURL() );
HttpURLConnection ConnObj = (HttpURLConnection) urlObj.openConnection();
ConnObj.connect();
BufferedReader br =
new BufferedReader(
new InputStreamReader(
ConnObj.getInputStream()
)
);
StringBuffer newData = new StringBuffer();
String s = "";
while ( null != ( (s = br.readLine() ) ) )
newData.append(s);
br.close();
return new String(newData);
}
como pode-se ver eu já estou tentando até outro encoder para fazer funcionar porém não obtive nenhum resultado.
se eu tiro o conversor de url (que deixa no urlencode) dá este erro.
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:1234/bramoto/contato_email.jsp
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1133)
br.com.brg.w3.WebSource.getSource(WebSource.java:50)
org.apache.jsp.contato_jsp._jspService(org.apache.jsp.contato_jsp:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
agora eu mudei o paradigma para este problema, eu estou botando num bean o formulário e tentando pegar ele em contato_email.jsp através do escopo session. porém quando a aplicação conecta na página ela muda de sessão. não to conseguindo resolver este problema agora.