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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:27:00+00:00 2026-05-16T15:27:00+00:00

This should be relatively simple to do but I’ve yet to find a description

  • 0

This should be relatively simple to do but I’ve yet to find a description of how to do it.

My setup is a simple web app that processes every request through a servlet (I’ll call it MyEverythingServlet for this question). Here’s a slightly modified version of my web.xml:

<servlet>
    <servlet-name>MyEverythingServlet</servlet-name>
    <servlet-class>blah.blah.blah.MyEverythingServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>MyEverythingServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Right now, the servlet is pretty simple and either does some work (when work.do is part of the path) and if a .txt file is specified in the path, we’ll do some validation and then load the file and send the text as the response:

response.getOutputStream().print( content );

What I’d like to do is either:

  • Inside the servlet, if the request is a URL to a .jsp file, I’d like to be able to have the container interpret the JSP scriptlet parts/taglib stuff before I write the String to the response.
  • Change my web.xml to have it process .jsp files outside of MyEverythingServlet.
  • 1 1 Answer
  • 1 View
  • 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-16T15:27:01+00:00Added an answer on May 16, 2026 at 3:27 pm
    • Inside the servlet, if the request is a URL to a .jsp file, I’d like to be able to have the container interpret the JSP scriptlet parts/taglib stuff before I write the String to the response.

    There’s no direct API available which processes JSP files programmatically like that. In theory, you’d like to have the JSP in public webcontent and forward the request to the JSP. You can do this with RequestDispatcher#forward().

    if (request.getServletPath().endsWith(".jsp")) {
        request.getRequestDispatcher(request.getServletPath()).forward(request, response);
    } else {
        // Write "plain" to response as you did.
    }
    

    You may only want to do some checks on the correctness of the paths, but this should at least give you the generic idea. There is however a little problem: the servlet will be invoked recursively since it’s mapped on /*. You’d rather replace this MyEverythingServlet by a Filter which just delegates the remnant of the job to the appserver’s builtin default servlet. Having a Servlet to listen on /* is already a design-smell indication that it should have been a Filter from the beginning on 😉

    • Change my web.xml to have it process .jsp files outside of MyEverythingServlet.

    You can’t have a “negative” url-pattern in web.xml. Best what you can do is to let the servlet listen on a more specific url-pattern like *.txt or /static/* and keep the JSP files there outside.

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

Sidebar

Related Questions

This should be a common scenario, but could not find any relevant post yet..
Okay, this seems like it should be relatively simple, but I've been Googling for
This looks like it should be a relatively simple query but can someone please
This should have been a relatively simple one but I must be making a
This should be relatively simple for the MVC experts out there, but I'm still
This should be simple, but the answer is eluding me. If I've got a
This should be a simple question, but I just can't recall the relevant API.
This should be painfully simple, but I cannot come up with a working connection
The app I'm working on is relatively simple but it is throwing memory warnings.
I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything

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.