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

  • Home
  • SEARCH
  • 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 8779229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:44:05+00:00 2026-06-13T19:44:05+00:00

I am calling a Servlet using its URL address. This is the URL I

  • 0

I am calling a Servlet using its URL address. This is the URL I am typing

http://localhost:7001/ryan/olympics?action=selectCatalog&id=1

This is the Servlet’s URL for sure; if I change the address I get

page not found

This is the code for the Servlet.

public class Servlet extends javax.servlet.http.HttpServlet
        implements javax.servlet.Servlet {

private static final long serialVersionUID = 1L;

public Servlet() {
    super();
}

public void init(ServletConfig config) throws ServletException {
    System.out.println("*** initializing controller servlet.");
    super.init(config);
}

protected void doPost(HttpServletRequest request,
  HttpServletResponse response) throws ServletException, IOException {


String action = request.getParameter("action");



if (action.equals("selectCatalog")) {
      String categoryId = request.getParameter("id");

      ProductModelDAO dao4 = new ProductModelDAOImpl("jpac");
      if (categoryId != null && !categoryId.trim().equals("")) {
          CategoryDAO dao1 = new CategoryDAOImpl("jpac");

    try {
        Category category = dao1.getCategoryName(categoryId);
        request.setAttribute("category", category);
        } catch (Exception e) {
        e.printStackTrace();
        }
    }

    try {
        @SuppressWarnings("unchecked")
        List<Product> products = dao4
            .getProductsByCategory(categoryId);
        request.setAttribute("products", products);
    } catch (Exception e) {
        e.printStackTrace();
    }

    url = "SelectCatalog.jsp";

 RequestDispatcher requestDispatcher =
  getServletContext().getRequestDispatcher(url);
requestDispatcher.forward(request, response);

I get the NullPointerException pointing to the RequestDispatcher‘s line. Any help?

  • 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-13T19:44:06+00:00Added an answer on June 13, 2026 at 7:44 pm

    Try changing "SelectCatalog.jsp" to "/SelectCatalog.jsp", because, as I understand, You want to use an absolute path.

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

Sidebar

Related Questions

Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
Is calling HttpServletResponse.addCookie(); (from servlet-api-2.5) multiple times using a cookie with the same name
I am using Spring MVC's charset filter. This is the URL that I use
I am calling a Servlet from index.jsp using Ajax. If the result is false,
I am calling a servlet from GWT client code using RequestBuilder. In the request
When i click a link im calling a servlet. When i click that link
Calling getActionBar returns null . This has been frequently reported so I've made sure
I am calling a servlet with params window.location.href = /csm/csminfo.jsp?CFG_ID=+cfgid+&path=+path; In the other csminfo
I am using simple HTML page for upload and post image to servlet then
I am calling a servlet from JavaScript with request parameters but the servlet 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.