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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:46:27+00:00 2026-05-17T18:46:27+00:00

Symptoms : Any JSP pages in the project produce error messages as below: org.apache.jasper.JasperException:

  • 0

Symptoms:

Any JSP pages in the project produce error messages as below:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 5 in the jsp file: /check.jspf
Generated servlet error:
*Duplicate local variable usr*

An error occurred at line: 5 in the jsp file: /check.jspf
Generated servlet error:
*Duplicate local variable path*

An error occurred at line: 5 in the jsp file: /check.jspf
Generated servlet error:
*Duplicate local variable pos*

An error occurred at line: 5 in the jsp file: /check.jspf
Generated servlet error:
*Duplicate local variable hSession*

An error occurred at line: 5 in the jsp file: /check.jspf
Generated servlet error:
*Duplicate local variable testRegister*

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    com.byinsight.logic.EncodingFilter.doFilter(EncodingFilter.java:22)

Ddevelopment environment:

  • JDK 1.5
  • Tomcat 5.0
  • IDE Eclipse 3.3

Reasons:

I was using jsp-config to include a JSPF in every JSP file. The web.xml is below:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <include-prelude>/check.jspf</include-prelude>
    </jsp-property-group>
</jsp-config>

The included file is check.jspf. The code in JSPF is below:

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.byinsight.model.User"%>
<%@page import="javax.servlet.http.HttpSession"%>

<%
    //String str = (String)session.getAttribute("login");
    User usr = (User)session.getAttribute("user");
    String path = request.getServletPath();
    int pos = path.indexOf("index.jsp");
    HttpSession hSession = request.getSession(false);
    String testRegister = (String)hSession.getAttribute("register");
    if (-1 == pos) {
        if ((null == usr) && (!testRegister.equals("login"))) {
            throw new RuntimeException("you have to login first ");
        }           
    }
%>

The project runs well in Eclipse, but when I deploy the WAR into product system, the error displays. I do not understand what does the error message means, the are no duplicate variables here! Somebody knows? Thank you very much!

  • 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-17T18:46:28+00:00Added an answer on May 17, 2026 at 6:46 pm

    I suggest to replace check.jspf by a Filter. Just put the same code in doFilter() method.

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpSession session = req.getSession();
        User usr = (User) session.getAttribute("user");
        String path = req.getServletPath();
        int pos = path.indexOf("index.jsp");
        String testRegister = (String) session.getAttribute("register");
        if (-1 == pos) {
            if ((null == usr) && (!testRegister.equals("login"))) {
                throw new RuntimeException("you have to login first "); // I'd just redirect to login page rather than throwing a RuntimeException.
            }           
        }
        chain.doFilter(request, response);
    }
    

    Replace the <jsp-config> by

    <filter>
        <filter-name>checkFilter</filter-name>
        <filter-class>com.example.CheckFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>checkFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    

    See also:

    • How to avoid Java code in JSP files
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm seeing the dreaded Code Sign error: The identity 'iPhone Developer' doesn't match any
Symptoms: Running any iOS 5.1 application from Xcode 4.4 (and 4.4.1) will launch the
Symptoms In IIS 7 and Dot Net 2.0 Integrated app pool: double clicking to
Symptom: Some users cannot successfully POST, most can successfully POST. When the error occurs,
I apologize if this is a duplicate but I couldn't find any solutions that
I am looking for a way to cure at least the symptoms of a
Below are the queries I am executing. But for some reason $MachineQuery is not
These are MY symptoms: (XP Pro, 32bit) -Programs that access .mdb databases (aside from
Is there any ready-to-use solution to log the memory consumption from the start of
I've used the UrlRewriting.Net module for a couple years now without any problems in

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.