• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet redirecting to a JSP compiled class file.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,

I have an application which uses JSP and Servlets. The Servlet contains all the business logic and redirects to a JSP class depending upon the request.

Now currently the application is very slow as the JSP is quite big. So what I am trying to achieve is instead of compiling JSP by the container I want to place compiled JSP in my .ear file. This will fasten the process as the container now don't have to compile my JSP.

My query is.

I have all the JSP in src/main/webapp/privatejsp/jsp.
Using maven-jsp plugin I am compiling all the JSP which generates the class file under target/WEB-INF/classes/jsp/privatejsp/jsp

But the problem is how to tell servlet to redirect to a .class file which is residing at WEB-INF/classes/jsp/privatejsp/jsp.

Currently I have the following code for redirecting to a jsp but will I redirect to a .class file.
getServletContext.getRequestDispatcher("/privatejsp/jsp/jspfileName.jsp").forward(req, resp);


Thanks and Regards,
Akshat Thapliyal
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You simply pass the path and classname to the dispatcher. Note that the class must be a Servlet though.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But the problem is how to tell servlet to redirect to a .class file

You don't. You still redirect/forward to the JSP as usual. The container will detect that it's been pre-compiled and not re-translate the JSP.

P.S. A large JSP is a red flag that you may be putting logic that belongs in the controller in the JSP.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sebastian Janisch wrote:You simply pass the path and classname to the dispatcher. Note that the class must be a Servlet though.


Huh?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Sebastian Janisch wrote:You simply pass the path and classname to the dispatcher. Note that the class must be a Servlet though.


Huh?



Gee, I got that totally mixed up .. My bad
 
reply
    Bookmark Topic Watch Topic
  • New Topic