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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:42:14+00:00 2026-05-18T03:42:14+00:00

I am currently writing an web application where you need to log in, using

  • 0

I am currently writing an web application where you need to log in, using username and password. The next step in the process is to select a Project in which the logged in user is involved.

Once the project is selected and the submit button has been clicked, a servlet is called to prepare the selected project and create a requestDispatcher and .forward the req and resp to my mainpage.

The layout of the mainpage:
The header div:

<div><jsp:include page="header.do" flush="true"/></div>

The body div:

<div>   code that is present in the mainpage.jsp </div>

The footer div:

<div><jsp:include page="footer.do" flush="true"/></div>

Lets say that these 3 divs make up the mainpage.

After forwarding the page with the requestDispatcher I get to see the mainpage’s content. However the <jsp:include>‘s are not loaded (the DIV’s are left empty). Only when I refresh the page (doGet, I assume) the includes will load correctly.

Is there anyway to let the includes load on a doPost requestDispatch execution?

**Note: The syntax of the requestDispatchers is exactly the same in the doPost and doGet methods.

If more clarification is needed, or extra code. Please let me know.


EDIT

Servlet container used:
Tomcat 6.0

Web.xml:

<!--- Servlet Mapping for Project Selection Servlet-->
<servlet>
    <servlet-name>ProjectSelect</servlet-name>
    <servlet-class>MyProject.Login.ProjectSelect</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ProjectSelect</servlet-name>
    <url-pattern>/ProjectSelect.do</url-pattern>
</servlet-mapping>

But what would the servlet mapping have to do with the doGet and doPost?


Kind regards,

B.

  • 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-18T03:42:14+00:00Added an answer on May 18, 2026 at 3:42 am

    As mentioned in the comments, it looked like that the servlet which is listening on header.do and footer.do is restricted to GET requests only. You need to ensure that it is to be executed on POST requests as well.

    As to the new question in the comment:

    Why is the doPost() method called when a <jsp:include> is called from another jsp page?

    Because the method of the HTTP request as fired by the client accounts. The RequestDispatcher doesn’t fire a brand new HTTP request or so (it’s only the sendRedirect() who is doing that). The RequestDispatcher just reuses the initial request for the included/forwarded resources. The request method won’t be changed and remains in this case POST in the included/forwarded resources.


    That said, you’d probably like to redesign/refactor all your *.do servlets to a single central front controller servlet which has the necessary logic implemented in service() method to avoid duplicated/boilerplate clutter. Or even better, adopt a MVC framework like JSF, Struts(2), Spring-MVC, etc. For more detail, check this answer.

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

Sidebar

Related Questions

No related questions found

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.