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 6010011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:03:17+00:00 2026-05-23T02:03:17+00:00

Currently I have a servlet CsmServlet.java which is getting called by the client side,

  • 0

Currently I have a servlet CsmServlet.java which is getting called by the client side, here is the web.xml part

<servlet>
    <display-name>upload</display-name>
    <servlet-name>upload</servlet-name>
    <servlet-class>com.abc.csm.web.CsmServlet</servlet-class>
</servlet>

which is perfect. Now I have to use struts 2 and re factor all of my code so what shall i use in my struts.xml to call CsmServlet class.

Here is my struts.xml, right now i am making a redirect to a another page

<struts>
<package name="default" extends="struts-default" namespace="/">
    <action name="showResult">
        <result>/csminfo.jsp</result>
    </action>

</package>
</struts>

I’ll repeat my question,

  1. What shall i add to my struts.xml to make a request to CsmServlet class
  2. Do I require any changes in my web.inf?

My Servlet content

 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
 throws ServletException, IOException {

PrintWriter out = resp.getWriter();
Map<String, String> requestParamter=getParamMap(req.getParameterMap());
RequestTransformer transformer = new RequestTransformer(req);

//(map and operation type) goes to CSMData
CSMData data = transformer.transform(requestParamter);

RequestHandler handler = new RequestHandler(req);
String result = handler.handle(data);

log.info(result);
out.println(result);

}
private Map<String,String> getParamMap(Map<String,String[]> params)
{
Map<String,String> paramsMap = new HashMap<String, String>();
for(Map.Entry<String,String[]> entry : params.entrySet())
{
paramsMap.put(entry.getKey(),entry.getValue()[0]);
}
return paramsMap;

}
  • 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-23T02:03:18+00:00Added an answer on May 23, 2026 at 2:03 am

    As Struts implements the MVC architecture, ideally you would not want to have your servlet doing the controlling part. You may want to copy the logic from your servlet to the Struts action.
    In general, you would have two options:

    1. Dont have servlets in you code (as
      controllers) and let the struts
      handle controlling. Copy the
      business logic from servlets (if
      any) into the actions of struts.
    2. In case you dont want bigger changes, you could forward you request from Strut’s action to the already created servlets.

    Hope this helps.

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

Sidebar

Related Questions

I'm currently trying to learn HTML and Java EE Servlet programming. I have an
Currently, I have a servlet act as web service. When I pass in parameters
I have created a basic servlet to handle logins on my web app. currently
I have a servlet running in an Oracle OCCAS server. Currently I map some
I have an applet that communicates with a servlet using Http (Not sockets). Currently,
I currently have a fairly robust server-side validation system in place, but I'm looking
I have two web applications running in same Servlet container ( Tomcat ), A
We currently have a Stateful bean that is injected into a Servlet. The problem
I currently have a Tomcat + Apache HTTP server setting to serve my Java
I have a Java EE application consisting of 1 web module and 1 EJB

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.