Results 1 to 5 of 5
Thread: Servlets or JSP?
- 08-31-2012, 09:40 AM #1
Member
- Join Date
- Aug 2012
- Posts
- 1
- Rep Power
- 0
Servlets or JSP?
Hello,
I'm creating a small web application using Servlets and I wonder is it necessary to use JSP pages. I've read a little about it and I think I can use it, but it's easier for me to use Servlets and PrintWriter - I have some experience with it. Is something wrong in using only Servlets without JSP? Should I connect these two technologies together somehow?
- 08-31-2012, 10:29 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Servlets or JSP?
It gets pretty messy using PrintWriter for outputting your HTML.
JSPs are a lot neater for that, which is why they were created.
Just don't mix code into the JSP...but then you are learning in the correct (IMO) order, so hopefully you won't.
Do all the work of getting any data together that needs to be displayed by the JSP, then simply forward there and use the JSTL tags (or whatever other framework you may be using) to display that data.Please do not ask for code as refusal often offends.
- 10-19-2012, 05:19 PM #3
Member
- Join Date
- Sep 2012
- Location
- Guntur, India
- Posts
- 27
- Rep Power
- 0
Re: Servlets or JSP?
JSP in fact internally uses Servlet code, it dynamically generates Servlet classes having the code that you've written in JSP. JSP is much easier to learn and even you need not restart Tomcat, when you do work with JSP files (modify the code in them).
But JSP is quite slow when compared to that of Servlets, as said earlier, JSP container has to generate servlet classes which takes time, i can say better use Servlets if it is small. They have got really good features.
- 10-21-2012, 12:38 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Servlets or JSP?
Again with the guesswork.
Servlets are for doing the processing and calling the business logic.
JSPs are for displaying the results.
That's all there is to it.Please do not ask for code as refusal often offends.
- 12-15-2012, 08:19 AM #5
Member
- Join Date
- Dec 2012
- Location
- china
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Servlets class not teaching servlets
By tsky in forum Java ServletReplies: 5Last Post: 04-26-2011, 10:47 PM -
mvc using servlets and jsp
By dush_gos in forum Java ServletReplies: 6Last Post: 07-09-2010, 11:32 PM -
servlets
By priyacvr in forum Java ServletReplies: 2Last Post: 09-28-2009, 07:43 AM -
Servlets
By javahelp00 in forum New To JavaReplies: 1Last Post: 02-28-2009, 06:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks