I will focus on the part of converting your jsp to text.
There were some comments about using jsp as a mechanism for creating illustrations, but my suggestion is agnostic for the temple.
The idea is to simulate a browser call, that is, send the form that we want the result to be emailed to, and make sure that we can access this page correctly through the browser.
I assume that the mail request is changing here to get this easily.
public class MailServiceHelper {
public String getJsp(String url, Map<String,String> form, HttpServletRequest request) {
String baseUrl ="";
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(baseUrl+"/"+url);
for (String formElement : form.keySet()) {
method.setParameter(formElement, form.get(formElement));
}
try {
int statusCode = client.executeMethod(method);
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
byte[] responseBody = method.getResponseBody();
return new String(responseBody,StandardCharsets.UTF_8);
}else{
throw new RuntimeException("Failed to read jsp, server returened with status code: "+statusCode);
}
} catch (Exception e) {
throw new RuntimeException("Failed to read jsp",e);
}finally{
method.releaseConnection();
}
}
, .
httpclient 3.1 exanple, . http 3.1, .
HTML : HTML-?
, html.