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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:27:18+00:00 2026-05-20T10:27:18+00:00

I used to just use Tomcat and JSP pages which I can execute query,

  • 0

I used to just use Tomcat and JSP pages which I can execute query, then assign query result into the array or object then pass that data onto client side via response.

request.setAttribute("errorMessage", "this is error!!");
request.getRequestDispatcher("report.jsp").forward(request, response);

In client jsp code, I could do something like:

${errorMessage}

Then the “this is error!!” message would show up.

I want to do the same thing with REST JAX-RS GlassFish v3.

    @Path("schedule/test")
    @POST
    @Consumes("application/x-www-form-urlencoded")
    @Produces("application/vnd.ms-excel")
    public Object tmpTest(String content) {
        try {

            //just my method to execute query and get result
            Vector out = (Vector)QueryManager.executeQuery;

            //if query result is empty, I want user to redirect to report.jsp page
            if(out.isEmpty()) {
                request.setAttribute("errorMessage", "This is error!!");
                request.getRequestDispatcher("report.jsp").forward(request, response);
                return null;
            }
        ....continue code......
   }

This results in mysterious exception I’ve never seen.

java.lang.ClassCastException: $Proxy109 cannot be cast to org.apache.catalina.core.ApplicationHttpRequest
            at org.apache.catalina.core.ApplicationHttpRequest.getRequestFacade(ApplicationHttpRequest.java:1001)
            at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:472)
            at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)

So how can I redirect a user to report.jsp and also pass message like “This is error” ?

The client jsp expects the error msg variable to have a value:

<b>${errorMessage}</b>
  • 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-20T10:27:19+00:00Added an answer on May 20, 2026 at 10:27 am

    That’s not RESTful. You need to throw a WebApplicationException with a specific status code so that the client understands what exactly went wrong. E.g. when it’s actually the server’s mistake:

    throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    

    Or when it was after all client’s mistake:

    throw new WebApplicationException(Response.Status.BAD_REQUEST);
    

    See also HTTP status code definitions for an overview.


    The ClassCastException which you’re facing is by the way occurring because the dispatched request is actually not an instance of the servletcontainer-provided implementation (in this particular case, the one of Tomcat or a Tomcat-fork). After all, you shouldn’t be doing it this way. You’re developing a REST webservice, not a JSP/Servlet website. It are two distinct worlds.

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

Sidebar

Related Questions

Just forgot the command which I used to execute at DOS Prompt to list
I just can't remember the terminology used for this and other related properties. EDIT
I just saw a article on Swing being used in JavaFX. How can an
I personally used Mercurial and Subversion in a limited way and I just can't
What win32 calls can be used to detect key press events globally (not just
I just wanted to compare different solutions used when implementing ACLs in Rails.
I'm just wondering if the same thread is used for each session, or if
I'm just trying to get a general idea of what views are used for
I'm used to thinking of member functions as just being a special case of
One simple method I've used in the past is basically just creating a second

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.