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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:24:00+00:00 2026-06-04T07:24:00+00:00

In my web.xml, I set up a servlet like <servlet> <servlet-name>forward</servlet-name> <servlet-class>test.Forward</servlet-class> </servlet> <servlet-mapping>

  • 0

In my web.xml, I set up a servlet like

<servlet>
    <servlet-name>forward</servlet-name>
    <servlet-class>test.Forward</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>forward</servlet-name>
    <url-pattern>/f/*</url-pattern>
</servlet-mapping>

test.Forward#doGet is implemented as

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.getRequestDispatcher("target.jsp").forward(req, resp);
}

When visiting localhost:8080/project/f/anypath, server crashes due to a stack overflow error.

It seems that RequestDispatcher#forward sets up another request to /f/target.jsp, and then test.Forward#doGet is called again, and then again. I somehow misunderstood RequestDispatcher#forward that I thought it as just render a page.

So, are there any methods that just render JSP?

  • 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-04T07:24:01+00:00Added an answer on June 4, 2026 at 7:24 am

    Your servlet path is /f/*, and you’re redirecting to a file that is on that path, most likely unintentionally:

    /f/target.jsp
    

    As a result, this creates an endless loop as your servlet keeps calling itself again and again and again.

    If you want to redirect to the JSP, I’m assuming it’s located in another folder like a /jsp/target.jsp location? If so, then make sure you include the full path:

    req.getRequestDispatcher("/jsp/target.jsp").forward(req, resp);
    

    When you leave out the /, the request is forwarded relative to the current requestURI.

    • 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
I have a spring mvc project set up like so: <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param>
Is it possible to set welcome-file tag from standard web.xml file by servlet 3.0
I have set my error page like this in web.xml: <error-page> <exception-type>java.lang.Exception</exception-type> <location>/errors/error.jsp</location> </error-page>
I have this in my applicationContext.xml <bean class=org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter /> <mvc:annotation-driven conversion-service=conversionService/> <bean id=conversionService class=org.springframework.context.support.ConversionServiceFactoryBean>
My web.xml is: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd id=WebApp_ID version=2.5> TestStruts2 <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name>
Is there a way, at the web server level (web.xml) to set headers for
I'm using WebSphere 7. I have a simple example set up with web.xml as
Get sunrise time and sun set times from xml from web. This is the
My web.xml is like <web-app version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd> <display-name>sample</display-name> <servlet> <servlet-name>Sampleclass</servlet-name> <servlet-class>sample.SampleClass</servlet-class>

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.