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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:43:09+00:00 2026-06-04T16:43:09+00:00

I am using Spring in my JSP project: I have following mapping for all

  • 0

I am using Spring in my JSP project:

I have following mapping for all HTML requests:

<servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
</servlet>

and

<servlet-mapping>
   <servlet-name>spring</servlet-name>
   <url-pattern>*.html</url-pattern>
</servlet-mapping>

So each request goes to the dispatcher.

I have a JSP page, which has session.getAttribute(), which returns sessions variables to that page.

If some user accesses that page directly, then the session variable is returned as null.

To avoid this, I tried adding the following line in the JSP page:

<%@page errorPage="error.jsp"%>

The JSP file is in the same directory where that page is, but no luck. I am getting the following exception: –> 404

I also tried a combination, so that errorPage would point as follows:

<%@page errorPage="../error.jsp"%> still not working

Then, I added an entry in the Controller as follows:

 @RequestMapping("/xyz/result/error")
        public ModelAndView showErrorPageEng() {
            return new ModelAndView("errorpage", "command", null);
        }

Updated Part of Question:

I have the following tiles entry for errorpage:

<definition name="errorpage" extends="basic"
    template="/error/error_layout.jsp">
    <put-attribute name="error" value="/error/error.jsp"/>  
</definition>

And modified code in the JSP as:

<%@page errorPage="error.html"%>

The above path /xyz/result/error is as follows:

ROOT/xyz/result/error

I can access the file mydomain/xyz/result/error.html but the same is not happening, with the following exception:

Starts as

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
at org.apache.jsp.error_jsp._jspService(error_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)


**and ends as** 

    at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:220)
    at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
    at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
    at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:659)
    at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:678)
    at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
    at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
    at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549

)

  • 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-04T16:43:10+00:00Added an answer on June 4, 2026 at 4:43 pm

    Another possible solution that builds on @pradeep’s existing solution is to use the HttpServletResponse object to redirect to the static HTML page.

    While static HTML pages cannot be used in JSP scriplet page declarations, existing paths accessible by the browser are something that the server can redirect the user to.

    The advantage of such a solution is that the HTML stays where it belongs, inside the HTML files, instead of in Java strings. This creates a more maintainable environment where code is readable by Java engineers and accessible by Web developers, yet still builds on top of the proposed workaround.

    Java:

    String  myObject= (String)session.getAttribute("finalList");
    
        if(myObject==null)
            {
    
                // redirect to the error page, using static HTML
                response.sendRedirect("/errorPage.html");
                return;
    
            }
    

    errorPage.html:

    <html>
    <head></head>
    <body>
      <div class="content">
        <div class="mainbarWH">
            <div class="article">
            <h2 class="style1">Sorry !</h2>
            <div class="clr style1"></div>
            <p class="style1">
                <strong>Your session has been expired </strong>
            </p>
            <p class="style1">Please go to <a href="engineering.html">Home</a></p>
         </div>
       </div>
       <div class="clr"></div> </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using spring mvc 3.0,jsp,mysql. I have table tbl_employee and it's attributes are
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
i have been using the spring mvc frameworks lately for a university project. Could
I have a project setup using Spring 3, Apache Tiles 2 and Maven. Before
I have a Mavenized Spring MVC project that deploys locally or remotely (passing all
I'm using Eclipse/Spring source to edit JSP tags and EL. If I want to
I am a newbie iam using jstl and spring,here i am having a jsp
Using Spring 2.5 tag library, I have an Integer value in a command form
I'm using spring MVC and spring security. I have annotation-driven controller and trying to
I am using spring and I have a child model with a objectify key

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.