I want to achieve the 2 things at the same time.
I have a regular jsp page in Struts2. xx/yy/zz/email.jsp
<html>
<head>
</head>
<body>
<s:property value="email"/>
</body>
</html>
The url of this page could be xx/yy/zz/myEmail.action, while some action class will handle it...
public class MyEmailAction {
private String email;
public String execute(){
this.email = 'abc@xyz.com''
}
//setter and getter for 'email'
......
}
Now, I would like to have another action, which sends the result of the page of xx/yy/zz/myEmail.action as email.
public class MyEmailAction {
private String email;
public String execute(){
this.email = 'abc@xyz.com''
}
public String send() {
this.email = 'abc@xyz.com''
Map mapping;
//put this.email into the mapping
String result = getResultOfJSP('../../../xx/yy/zz/email.jsp', mapping);
Email.send('me@me.com', 'you@you.com', 'My Subject', result);
}
//setter and getter for 'email'
......
}
So the question is that: HOW CAN I GET THE RESULT OF A RENDERED JSP AS A STRING?
This reason why I want this is obviously that I want to manage this template in one place (email.jsp).
I know I could use another velocity (vm) page which has exact the same html as the jsp but with velocity markups instead. But then whenever I need to make a change to this template, I have to do it on both places.
I think I could also use URL to grab the result, but I prefer not to use this way as it's another request to the server.
Thanks