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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:37:03+00:00 2026-05-31T22:37:03+00:00

I have a Servlet called Menu that generates some html and a dynamic menu,

  • 0

I have a Servlet called Menu that generates some html and a dynamic menu,
I mean by dynamic that the links in the menu change each time the user select a table in a frame, here is a quick exemple:

Browse?table=student
Search?table=student

Browse?table=professor
Search?table=professor

I included this Servlet in the beginning of most of my servlets in order to optimise modifications, I used the following code:

RequestDispatcher dispatcher = request.getRequestDispatcher("/Menu?table="+tableName);
dispatcher.include(request, response);

but when I try to send a post request to Servlet that contain the previous code, I receive an error saying:
HTTP Status 405 – HTTP method POST is not supported by this URL

I’m using NetBeans 6.9.1 and TomCat 6.0.26 and Java version 1.6

So is there any way to include my Servlet Menu in the POST method of another Servlet?
or is there another solution to have the dynamic menu other than a Servlet?

To explain more to you guys, here is the code of my Servlet:

public class ExecuteAnySql extends HttpServlet {

//No problem here
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//code
//include the Menu Servlet
//code
}

//this does not work when I include the Menu Servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//code
//include the Menu Servlet
//code
}

}

Thanks guys, I think that I found a solution,

The solution you provide me will work only if I have 1 Servlet, but I have too many and I want that they share the same menu.

So all I have to do is to make a static method that takes the table name as a parameter and generate the html code.
If I proceed like this, I can call my method from all of my Servlets.

  • 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-31T22:37:04+00:00Added an answer on May 31, 2026 at 10:37 pm

    You need to provide POST support in the servlet. The servlet template that Netbeans uses by default does this for you. But simply provide a single method that does the work of the servlet:

       public void doEverything(HttpServletRequest request, HttpServletResponse response){
              //all your servlet code here
       }
    

    Then in the doPost you can simply call this method and in your doGet you can call this method like this:

       doEverything(request, response);
    

    This way the single servlet handles both GET and POST.


    So expanding on your posted code:

    public class Menu extends HttpServlet {
    
    //No problem here
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
             doEverything(request, response);
    }
    
    //this does not work when I include the Menu Servlet
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {   
            doEverything(request, response);
    }
    
    protected void doEverything(HttpServletRequest request, HttpServletResponse response){
        //do actual menu code
        //forward to the requested servlet
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet that is called from a link on another page. The
I have code called from a servlet that calls out to an external service.
I have an implementation of javax.servlet.http.HttpSessionListener that is supposed to detect user session invalidation/timeout
I have a servlet that is used for many different actions, used in the
I have a servlet running in an Oracle OCCAS server. Currently I map some
I have a servlet that I would like to run within ColdFusion MX 7.
Under JBoss 4.0.1SP1, I have a servlet that makes multiple, concurrent calls to web
Suppose that I have a method called doSomething() and I want to use this
I have a table that contains a column called 'id' that is an INT
In my web-app I have a servlet that acts as the index. It is

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.