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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:58:54+00:00 2026-06-14T17:58:54+00:00

I need to include .jsp file in my servlet. I have written simple jsp

  • 0

I need to include .jsp file in my servlet.

I have written simple jsp file, which i have put in dir WEB-INF/jsps/:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title> Galleries </title>
</head>

<body>
Test
</body>
</html>

and servlet:

package photoGallery;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class GalleriesServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    {
        try 
        {
            System.out.println("Test");
            //get the request dispatcher
            RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsps/galleries.jsp");
            //forward to the jsp file
            if (dispatcher != null)
                dispatcher.forward(request, response);
            else 
                System.err.println("Error: dispathcer is null");        
        } 
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

in web.xml I have added next lines:

  <servlet>
    <display-name>Gallery Servlet</display-name>
    <servlet-name>GalleryServlet</servlet-name>
    <servlet-class>photoGallery.GalleriesServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>GalleryServlet</servlet-name>
    <url-pattern>/galleries/*</url-pattern>
  </servlet-mapping>

When I’m openning page

http://localhost:8080/PhotoGallery/galleries

then in console it prints “Test”, but in browser I see “HTTP Status 404 – Not Found”

Where I have made mistake?

  • 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-14T17:58:55+00:00Added an answer on June 14, 2026 at 5:58 pm

    I have found my mistake.
    There was other servlet which was mapped to “/*”, and because of that appeared errors

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

Sidebar

Related Questions

I want to write a simple web page in .jsp file. I need to
I need to include a GWT file into JSP page. The GWT resource is
i have several CSS styles i would need to include in the JSP page,
I have web pages generated by JSP which sometimes also include jQuery code. Some
Good day, I have a requirement which i need to include a layout (actually
I need to define a jsp tag which named include. It should be used
I have written web apps with JSP in the past. Now, I'm getting started
I have a project in Java thgat needs to use; <%@include file=content.jsp %> to
I need to access a page allCommonPageLink.jsp from another page named add_edit.jsp I have
I need to include jsp pages to a jsp page. I had page=<%=contextPath%>/admin/admin_left.jsp and

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.