I have an email utility class that is used by all my web applications on the network that send employees their forgotten password (well, the class is copied to every webapp). I need to mark up an email with the appropriate subject line, contact point of contact, the name of the application, etc., which corresponds to the application that calls it.
I can pass them as parameters, but the way I do this is to include initialize.jspin my header on the login web page.
<% request.setAttribute("siteEmail", "Commitment@<domain>.com");
request.setAttribute("siteName", "Commitment Report Database");
request.setAttribute("sitePOCEmail", "smith@<domain>.com");
%>
These request parameters are then stored in the DTO through a similar Struts action.
public class STKRequestPasswordAction implements ControllerAction {
public STKRequestPasswordAction() {}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ApplicationConfig ac = new ApplicationConfig();
ac.setAppEmail(request.getAttribute("siteEmail").toString());
ac.setAppName(request.getAttribute("siteName").toString());
ac.setPocEmail(request.getAttribute("sitePOCEmail").toString());
request.setAttribute("ac", ac);
userForm.requestPassword(LoginUser, ac);
UserForm.requestPassword method
public void requestPassword(STKUser loginUser, ApplicationConfig ac) {
checks the entered user ID asking for the password, builds a StringBuffer message, and then calls the Email Utility class.
EmailUtils.sendEMailByBadge(loginUser.getBadge(), strFrom, strReplyTo, strSubject, emailBody.toString(), strSMTP, true);
jsp web.xml, , . POJO
String strFrom = getServletContext().getInitParameter("siteEmail");
POJO . , , :
actionMap.put(null, new STKLoginSubmitAction());
actionMap.put("chkpass", new STKLoginSubmitAction());
actionMap.put("sqlReset", new STKRequestPasswordAction());
String op = request.getParameter("method");
ControllerAction action = (ControllerAction) actionMap.get(op);
ApplicationConfig ac STKRequestPasswordAction, `ac '. ?