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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:46:41+00:00 2026-06-08T15:46:41+00:00

I’m still pretty new to programming Java servlets, so apologies in advance if I’m

  • 0

I’m still pretty new to programming Java servlets, so apologies in advance if I’m going about this wrong. (But if so, I’d appreciate any help!)

My web site is going to have two main parts: a web service part and an “everything else” part, the latter of which will be servicing most of the interactive browser requests. I thought I’d be able to get away with something like this in my web.xml file:

<servlet>
    <servlet-name>Webservice</servlet-name>
    <servlet-class>com.mydomain.webservice</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Webservice</servlet-name>
    <url-pattern>/webservice/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>Interactive</servlet-name>
    <servlet-class>com.mydomain.interactive</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Interactive</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

The intention is for the web service, which communicates via either AJAX, via a fat client application, or other RPC method, to use URLs that all start with mydomain.com/webservice, such as:

  • mydomain.com/webservice/login
  • mydomain.com/webservice/viewuser/12345
  • mydomian.com/webservice/deleteitem/abc
  • …

However, people browsing the site normally using a browser would access the site as:

  • mydomain.com (home page)
  • mydomain.com/login
  • mydomain.com/viewuser/12335
  • mydomain.com/deleteitem/abc
  • …

In my interactive class, I’m parsing the getPathInfo() result to forward the request to another class, and the vast majority of most of those classes are using a request dispatcher to forward info to view JSP files to actually render the HTML. So a snipped of code in one of my classes might look like:

RequestDispatcher view = req.getRequestDispatcher("/WEB-INF/views/master.jsp");
view.forward(req, resp);

I also do have error checking in the interactive servlet so that if a user tries to access a URL that isn’t routable (for example, mydomain.com/foobar when I haven’t defined anything to handle foobar), it throws an HTTP 404. When I fire it up, though, everything generates an HTTP 404.

After some troubleshooting, I figured out that the request is making it to the servlet without any issue, and the servlet is parsing it correctly. However, when it tries to forward it to /WEB-INF/views/master.jsp, it invokes the servlet again. I thought that WEB-INF was a “magic” directory that represented publicly inaccessible resources, but it looks like my Java container (Jetty, via the Google App Engine plug-in for Eclipse) is treating it like an attempt to access a URL. I’m guessing it’s because when I define /* as the url-pattern in my web.xml file, it’s literally interpreting that as, send everything to that servlet, including calls to forward a request to a JSP view file within the WEB-INF directory.

Am I doing something wrong? I haven’t even gotten to trying to handle requests to the web service yet and I’ve gotten stuck on just trying to handle requests to the interactive site. Any help would be greatly appreciated!

  • 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-06-08T15:46:43+00:00Added an answer on June 8, 2026 at 3:46 pm

    The solution to your original problem is very easy – you should configure your servlet as a default one:

    <servlet-mapping>
        <servlet-name>Interactive</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    Note the / pattern. This way it will handle requests not handled by other servlets (unlike /* mapping, that handles all the requests).

    However, this approach causes problems with serving static content. If you have static content to be served you may need more sophisticated solutions, see, for example, Using Spring, mapping to root in web.xml, static resources aren’t found.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.