Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet redirecting to a JSP compiled class file.

 
Thapliyal Akshat
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You simply pass the path and classname to the dispatcher. Note that the class must be a Servlet though.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
It's just a flesh wound! Or a tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!