wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to use both JSP and Servlets in an application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to use both JSP and Servlets in an application" Watch "How to use both JSP and Servlets in an application" New topic

How to use both JSP and Servlets in an application

Sunny Raj

Joined: Apr 23, 2002
Posts: 6
Is it possible to use both JSPs and Servlets in developing a single application? Call Servlets from JSPs?
I am fairly new to server-side programming and I was looking for tutorials on this subject but have been unsuccessful so far. Can anyone help?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

It is possible to call servlets from JSP and vice-versa. For tutorial on servlets visit http://java.sun.com/docs/books/tutorial/servlets/ and http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html.
For JSP http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro.html.

Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
Links at this page might help too :

Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

And two more resources.... check out Core Servlets and JavaServer Pages by Marty Hall -- it's available online. It covers the Servlet 2.2 and JSP 1.1 specifications.
More Servlets and JavaServer Pages by Mary Hall is the follow-upbook which covers the Servlet 2.3 and JSP 1.2 specifications.
Both are excellent books.

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 128
Thanks for the information. You always learn something when you visit the Ranch.

Darryl Failla
Sun Certified Java 2 Programmer
Angela Margot
Ranch Hand

Joined: Feb 07, 2002
Posts: 80
Marty's tutorial on Servlets is at:
And yup, you can implement servlets in JSP!

Angela Margot <img src="smile.gif" border="0"> <br />Sr. Software Engineer<br />SCJP2 SCWCD MCSD MCP
arun sahni
Ranch Hand

Joined: Jan 16, 2002
Posts: 91
After learning you can use MVC framework like Struts to make life easier.

Arun Sahni<br />SCJP2,SWCD,<br />BEA Certified Specialist: Server <br />JCert Enterprise Developer for BEA.
Sunny Raj

Joined: Apr 23, 2002
Posts: 6
Thanks for all the information. So far, it is only in the "Core Servlets..." book by Marty Hall that I noticed a chapter on "Integrating JSPs and Servlets". While I am waiting to get this book, can someone give me a quick example of how a Servlet can be called from a JSP? I know how to call beans and XML parsing and SAX etc.
wood burning stoves
subject: How to use both JSP and Servlets in an application
Similar Threads
diff b/w servlet&jsp
Is Tomcat an app server.
Listener in JSP
Do web container and ejb conatiner share the same JVM