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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:36:01+00:00 2026-05-17T22:36:01+00:00

I have made small web-app in jsp with a start page with login and

  • 0

I have made small web-app in jsp with a start page with login and some restricted pages with logout, -everything controlled with filters and servlets. I started making it because I wanted to learn how to use filters and servlets, and think I have succeded in that very well.

Everything works fine when I just ensure everything is happening in the ‘root’ url-pattern, but the problem is I want the restricted pages to be in its own url-pattern directory…

On my restricted pages I have included (<@ include…>) a Logout page which contains this form:

<form method=POST action=LC>
<table align="right">

 <tr>
  <td>Navn:</td>
  <td><b><%=login.getName() %></b></td>
 </tr>
 <tr>
  <td>Aktør:</td>
  <td><b><%= login.getAktoer() %></b></td>
 </tr>
 <tr>
  <td><input type="submit" value="Log ud"></td>
 </tr>
 <tr>
  <td></td>
  <td><b><%= login.getMeddelelse() %></b></td>
 </tr>
</table>
</form>

The submit on this page will send the user to a control servlet that just clears a LoginBean, sets a boolean isLoggedin value to false on the same bean and finally ‘sendRedirect’ the user to my start page. This works well when all pages are in the ‘root’ url-pattern directory.

One of my restricted pages is Yellow.jsp. As it is now, it just have following servlet mapping:

<servlet>
    <servlet-name>ptYellow</servlet-name>
    <jsp-file>/Yellow.jsp</jsp-file>
  </servlet>
  <servlet-mapping>
    <servlet-name>ptYellow</servlet-name>
    <url-pattern>/Yellow.jsp</url-pattern>
  </servlet-mapping>

what I want it to be is this:

<servlet-mapping>
    <servlet-name>ptYellow</servlet-name>
    <url-pattern>/RestrictedPages/YellowZone/Yellow.jsp</url-pattern>
  </servlet-mapping>

But when I try to map it like this and I attempt a logout from the Yellow.jsp page, it just spits out a 404 error because it is attempting to access my logout control servlet in the ‘/RestrictedPages/YellowZone/’ directory.

it tries to access:

http://localhost:8080/myapp/RestrictedPages/YellowZone/LC

(LC is my Logout Control servlet)

when it should just go for:

http://localhost:8080/myapp/LC

I want to include my logout on many different restricted pages in different url-patterns, so it should not be mapped to the same url-pattern (that doesn’t seem to solve the problem anyways).

And I definitely don’t want to hard code the logout form on all restricted pages, when I know it should be possible to just ‘include’ it…

I’m guessing I have to write something special in my logout forms action attribute, but can not figure out what to write. I have tried stuff like:

action=*/LC

and

action=/../LC

Stripped from most irrelevant code, my xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
version="3.0">
  <welcome-file-list>
    <welcome-file>StartSide.jsp</welcome-file>
  </welcome-file-list>
  <error-page>
    <error-code>404</error-code>
    <location>/404.jsp</location>
  </error-page>
  <filter>
    <filter-name>LoginFilter</filter-name>
    <filter-class>control.LoginFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>LoginFilter</filter-name>
    <servlet-name>AC</servlet-name>
  </filter-mapping>
  <filter>
    <filter-name>YellowFilter</filter-name>
    <filter-class>control.YellowFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>YellowFilter</filter-name>
    <url-pattern>/RestrictedPages/YellowZone/*</url-pattern>
  </filter-mapping>

  <servlet>
    <servlet-name>ptYellow</servlet-name>
    <jsp-file>/Yellow.jsp</jsp-file>
  </servlet>
  <servlet-mapping>
    <servlet-name>ptYellow</servlet-name>
    <url-pattern>/RestrictedPages/YellowZone/Yellow.jsp</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>start</servlet-name>
    <jsp-file>/StartSide.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>start</servlet-name>
    <url-pattern>/start</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>AC</servlet-name>
    <servlet-class>control.ActorControl</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>AC</servlet-name>
    <url-pattern>/AC</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>LC</servlet-name>
    <servlet-class>control.LogoutControl</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LC</servlet-name>
    <url-pattern>/LC</url-pattern>
  </servlet-mapping>

</web-app>

Would be awesome if someone can point out what I’m doing wrong… I can see a lot of potential in using filters on url-patterns, but it is no use to me when I can’t do simple stuff like moving back in a url-pattern….

I am using Eclipse Helios and apache-tomcat 7.0, if that has any relevance…

(I have used hours trying to search for an answer, but I don’t think I know exactly what to search for)

EDIT: typos and clarification

EDIT2: I have tried to do some mapping on my Logout.jsp page (which is the log out page that I ‘include’ on my restricted pages), but that doesn’t seem to solve the problem either…

EDIT3:I have poked some more around with this problem tonight.

I tried to add this block of code to my YellowFilter.java (and added the name=Logout to the submit button in Logout.jsp):

try{
        if(httpReq.getParameter("logout").equals("Log ud"))
            httpResp.sendRedirect("LC");
        } catch(NullPointerException e)
        {
        }

it didn’t work either, it still just tries to access

http://localhost:8080/myapp/RestrictedPages/YellowZone/LC

I also tried removing the action parameter from my logout form, so it would just POST to the same page. That didn’t help either…

Furthermore I have tried to edit the servlet-mapping for my Logout control servlet in the xml file:

<servlet-mapping>
    <servlet-name>LC</servlet-name>
    <url-pattern>/*/*/LC</url-pattern>
  </servlet-mapping>

didn’t work, then I tried:

<servlet-mapping>
    <servlet-name>LC</servlet-name>
    <url-pattern>/*/LC</url-pattern>
  </servlet-mapping>

didn’t work either, so then I tried:

<servlet-mapping>
    <servlet-name>LC</servlet-name>
    <url-pattern>/*LC</url-pattern>
  </servlet-mapping>

and that didn’t work either…

/sigh, very annoying problem, and can’t let it go…

  • 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-17T22:36:02+00:00Added an answer on May 17, 2026 at 10:36 pm

    I found a very simple solution to the problem. I just change the form method in Logout.jsp to method=GET instead of POST, and then write action=/’myappname’/’name-of-servlet’:

    <form method=GET action=/Prototype/LC>
    <table align="right">
    
        <tr>
            <td>Navn:</td>
            <td><b><%=login.getName() %></b></td>
        </tr>
        <tr>
            <td>Aktør:</td>
            <td><b><%= login.getAktoer() %></b></td>
        </tr>
        <tr>
            <td><input type="submit" value="Log ud"></td>
        </tr>
        <tr>
            <td></td>
            <td><b><%= login.getMeddelelse() %></b></td>
        </tr>
    </table>
    </form>
    

    The solution is pretty obvious to me now, and I fell stupid about overlooking this, -so I really hope someone else is having the same problem xD…

    Will change the title of my question to ‘Go back in url-pattern (invoking servlet from a jsp page)’

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

Sidebar

Related Questions

In the bug fixing of a small ASP.NET/C# web app I have made, I
i have made a small web application with form.html output.jsp ServletOne.java In the form.html,users
I have made an update on Google App Engine with a small fix and
I have a small problem developing/optimizing a web page. I know it is good
I have a web app that I provide to small to medium-sized businesses as
I've made a small web app using web.py that I now want to put
I'm working on a web app, and i already have a hosting. I made
I have made a small log service that i want to publish to a
I have made a small application in Java and I would like to make
Problem: Have made a small mail program which works perfectly on my developer pc

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.