File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet reading a JSP file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet reading a JSP file" Watch "Servlet reading a JSP file" New topic

Servlet reading a JSP file

Santanu Barua

Joined: Jul 10, 2001
Posts: 2
How would a servlet read a jsp file and display. I want to be able to display its contents after operations in the servlets...
ken chou
Ranch Hand

Joined: Feb 08, 2001
Posts: 68

I feel that by using "jsp + bean" can accomplish almost everything already. Can anyone give me some good reasons for using Servlet?
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
A good example of why you might want to use a Servlet is to process a HTML form submission. This relates back to the "Model-View-Controller" (MVC) architecture where a controller (in this case a Servlet) might perform some processing, modify the model (e.g. JavaBeans or EJBs) and then redirect the user to another view (in this case a JSP).
Splitting up the logic in this way allows you to decouple the processing from the view and therefore allows you to change either easily. This also achieves the "goal" of reducing the amount of Java code required inside JSPs.
Taking a more pragmatic approach, of course there's nothing stopping you processing forms with JSPs, especially for small applications.
Hope that helps.
Simon Brown
Co-author of Professional JSP 2nd Edition
I agree. Here's the link:
subject: Servlet reading a JSP file
It's not a secret anymore!