Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3494292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:59:18+00:00 2026-05-18T11:59:18+00:00

I have an email utility class that is shared by all my intranet web

  • 0

I have an email utility class that is shared by all my intranet web apps which emails an employee their forgotten password (well the class is copied into each webapp). I need to brand the email with appropriate Subject Line, ReplyTo Point Of Contact, Application Name, etc that matches the app that is calling it.

I’m able to pass these as parameters but the way I do it is by including an initialize.jsp in my header on the login webpage.

<% request.setAttribute("siteEmail", "Commitment@<domain>.com");
   request.setAttribute("siteName", "Commitment Report Database");
   request.setAttribute("sitePOCEmail", "smith@<domain>.com");
%>

These request parameter are then stored into a DTO by a Struts similar 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);

The userForm.requestPassword method

public void requestPassword(STKUser loginUser, ApplicationConfig ac) {

validates the inputed userID requesting the password, builds the StringBuffer message, and then calls the Email Utility class.

EmailUtils.sendEMailByBadge(loginUser.getBadge(), strFrom, strReplyTo, strSubject, emailBody.toString(), strSMTP, true);

I’d like to refactor my initializing parameters out of the included jsp and put them into the web.xml, but I am not sure where I should be reading the values. I tried this in the POJO

String strFrom = getServletContext().getInitParameter("siteEmail");
but there is no servletContext in the POJO. I would imagine it could go in my servlet but my servlet uses a mapping as follows:

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);

I plan to move ApplicationConfig ac to the servlet and change the method signature for STKRequestPasswordAction to pass `ac’. Is this the best approach or am I missing the picture?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:59:19+00:00Added an answer on May 18, 2026 at 11:59 am

    In your web.xml:

    <env-entry>
        <env-entry-name>myEntryName</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>myEntryValue</env-entry-value>
    </env-entry>
    

    In your Java code:

    // Do once
    Context env = (Context) new InitialContext().lookup("java:comp/env");
    
    // Do for every entry
    String entryValue = (String) env.lookup("myEntryName");
    

    Using JNDI you can read your settings every where in your webapp and also keep your configs out of your web.xml if you need, in context.xml for Tomcat or jetty-env.xml for Jetty for example (though format is different).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a User model that Devise manages - i.e. all users have email
My application has a utility class with static methods which are responsible for showing
I'm trying to create a user control template that I can send as email.
I have email functionality in my App. Along with the message body I attach
On GAE, a non-gmail user can create a Google Account using their non-gmail email
I have an application in Asp.net and using sql server to store user information.
So I noticed that My outlook.exe process was growing at a rate of roughly
The needs of my company are quite simple : We have a multi-threaded .Net
I'd like to make use of the Model Binding / Rendering capabilities of a
I need to validate 3 or more input fields (required at lest one). For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.