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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:22:47+00:00 2026-05-16T22:22:47+00:00

The URL below, the first content in the chosen answer describes JSP hiding. Hidden

  • 0

The URL below, the first content in the chosen answer describes JSP hiding.

Hidden features of JSP/Servlet

I so far understand that I can put jsp files under /WEB-INF directory. So that it prevents a user from direct access like http://test.com/WEB-INF/register.jsp (return 404)

I thought I understand but not and wants to describe better so I’m opening up the question here.

I have, say, 2 jsp files like below.

webapps/ROOT/home.jsp

webapps/ROOT/WEB-INF/register.jsp

NOTE: /go_register is mapped to the servlet class Register in web.xml (DD)

home.jsp

<html>
<body>
  <a href="/go_register">Go to register.jsp</a>
<body>
</html>

register.jsp

<html>
<body>
  <form method="post" action="/process_register">
  <input type="submit">
</form>
<body>
</html>

So.. since register.jsp resides under /WEB-INF/, only RequestDispatcher can access to it.
That means I need to create servlet for forwarding the request.

public class Register extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String address = "/WEB-INF/register.jsp";
        request.getRequestDispatcher(address).forward(request, response);
    }
}

But this looks not right. If I want to add login page /WEB-INF/login.jsp to home.jsp,
in order to access to the login.jsp, I have to create another servlet just for going to the login page purpose???

public class Login extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String address = "/WEB-INF/login.jsp";
        request.getRequestDispatcher(address).forward(request, response);
    }
}

I think I am using the technique in the wrong way. Could anyone explain how to use this jsp hiding?

  • 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-16T22:22:48+00:00Added an answer on May 16, 2026 at 10:22 pm

    You do have a Servlet which does the login task in the doPost() method? You could just add the necessary doGet() to it 🙂

    By the way, I would just map the Register servlet on a single url-pattern like /register so that you can use it in both <a href="/register"> (which will call doGet() method) and <form action="/register" method="post"> (which will call doPost() method) without having the unnecessary need for two servlet mappings.

    To get a step further, you can refactor this all into a single servlet which takes action accordingly based on the request URL. As you see, there is some code repetition which can be abstracted away. Normally, this is to be done by a MVC framework like Struts2, Spring-MVC, JSF2, etcetera, but you could also create a basic one yourself. More detail and code examples can be found in this answer.

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

Sidebar

Related Questions

I tried to install MVC Framework from the below URL http://www.asp.net/mVC/ First it is
I was searching for a pure CSS answer to hiding and showing content but
The link below is an image URL where the extension has been stripped. I
I typically use the below function to return the root URL if I ever
My script is generating a very long URL just like the one below and
In the code below, $row['site'] is an URL. In Chrome and IE8, it displays
The jQuery ajax script below doesn't work on my site if url is without
In the .htaccess example below, if someone types in a URL like the following...
What is the problem below? routes.MapRoute( Default2, // Route name {controller}/{action}/{id}, // URL with
My code below takes a URL inputted by the user and prints out the

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.