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

  • SEARCH
  • Home
  • 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 7196547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:47:53+00:00 2026-05-28T20:47:53+00:00

I have a url-mapping in my web.xml such that requests for a specific url

  • 0

I have a url-mapping in my web.xml such that requests for a specific url x.pt gets mapped to a Servlet say Servlet1. In the service() of this servlet I check if the request has some specific parameter.

If so, the call is delegated to another servlet Servlet2 by instantiating it and calling its service method.

public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {

    // if the call is for some special events (request has some specific parameter)
    if (req.getParameter(conditionCheck()) {
        doPost(req, res);
    } else {
        // Report parsing
    }
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {

    try {
        // instantiate Servlet2 object
        servlet2.init(this.getServletConfig());
        servlet2.service(req, res);
        servlet2.destroy();
    } catch (Exception e) {
        LOG.error("Unable to execute event", e);
    }
}

The browser returns some JSON text when the request is for special events( i.e. to Servlet2)
Do let me know if I need to do something extra for getting response of Servlet2 to the brwoser.

Thanks in advance!

  • 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-28T20:47:54+00:00Added an answer on May 28, 2026 at 8:47 pm

    You can forward your request using RequestDispacher:

    RequestDispatcher rd = getServletContext().getRequestDispatcher(destination);
    rd.forward(request, response);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have in web.xml: <param-name>transformWsdlLocations</param-name> <param-value>true</param-value> and <servlet-mapping> <servlet-name>personWS</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> auto-generated WSDL
Let's say I have this in my web.xml: <servlet> <description></description> <display-name>MainServ</display-name> <servlet-name>MainServ</servlet-name> <servlet-class>MainServ</servlet-class> </servlet>
I have a confusion regarding the structure of the web.xml for the servlet mapping,
Suppose I have following in my web.xml <filter-mapping> <filter-name>F1</filter-name> <url-pattern>/XYZ/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>F2</filter-name> <url-pattern>/XYZ/abc.do</url-pattern>
The following web.xml doesn't seem to work: <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>*.wfn</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>SelectSessionServer.wfn</welcome-file> </welcome-file-list>
I hit the maximum url-patterns that one can have in the web.xml and I
In my web.xml of my simple app i have <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>HelloServlet</servlet-class> </servlet> <servlet-mapping>
Why i have an error in my web.xml when i want add servlet..? <servlet>
I have standard servlet-mapping for Dispatcher Servlet - /app/* . I have controller that
I have a servlet Filter that acts as the basis of my web stack.

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.