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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:01:13+00:00 2026-06-12T02:01:13+00:00

I see a strange issue in a simple servlet chaining example that I am

  • 0

I see a strange issue in a simple servlet chaining example that I am trying:

Servlet 1:

public class gatewayservlet extends HttpServlet {

  public void doPost(HttpServletRequest request , 
    HttpServletResponse response)
    throws ServletException , IOException {
        doGet(request,response);
  }

  public void doGet(HttpServletRequest request , 
    HttpServletResponse response)
    throws ServletException , IOException {

    response.setContentType("text/plain");

    PrintWriter out = response.getWriter();

    name = request.getParameter("name");

    RequestDispatcher rd = getServletConfig().getServletContext().getRequestDispatcher("/justServlets/secondservlet");

    if(name!=null) {
      request.setAttribute("UserName",name);
      rd.forward(request , response);
      // Forward the value to another Secondservlet
    } else {
      response.sendError(response.SC_BAD_REQUEST, 
        "UserName Required");
    }

  }

}

Servlet 2:

public class secondservlet extends HttpServlet {

  public void doGet(HttpServletRequest request , 
    HttpServletResponse response)
    throws ServletException , IOException {

    response.setContentType("text/plain");

    PrintWriter out = response.getWriter();

    String UserName = (String)request.getAttribute("UserName");

    out.println("The UserName is "+ UserName);

  }


  public void doPost(HttpServletRequest request , 
    HttpServletResponse response)
    throws ServletException , IOException {
        doGet(request,response);
  }

}

And the invoking form:

<html>
<body>
<FORM ACTION="/justServlets/gateway" METHOD=POST>
<P>Please Fill the Registration Form</p><br>
Enter Your Name<input type="text" name="name"><br>
<input type="submit" value="send">
</FORM>
</body>
</html>

The ‘POST’ gives a 405(Method not allowed) error.
However ,invoking the first servlet as …./justServlets/gateway?name=Socrates works.
Whats the matter?

  • 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-12T02:01:14+00:00Added an answer on June 12, 2026 at 2:01 am

    This usually happens when the servlet you are forwarding do lacks a handler for the same method (in this case POST) as was originally handled. Make sure servlet2 does indeed handle doPost and that you are indeed forwarding to servlet2.

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

Sidebar

Related Questions

Disclaimer : this is a strange issue that only happens in a Kindle Fire
I'm using libevent to do simple POST http server, but i find strange issue
I'm running into a very strange issue here with wrong object state that I
I am seeing a very strange issue with a simple controller method. Either I
I see a strange issue where the ScrollTo plugin scrolls twice the expected distance,
I've got a strange issue with a simple select dropdown not displaying in IE8.
I am having a strange issue that I have never encountered in the past
When doing a simple performance measurement, I was astonished to see that calling String.IndexOf(char)
I have this strange issue with my web app. You see, I'm using jQuery
I just see strange behaviour in Eclipse . I am developing one android project

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.