This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes why to use JSP? 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 » JSP
Bookmark "why to use JSP?" Watch "why to use JSP?" New topic
Author

why to use JSP?

Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146
Hi i have a basic doubt.

Why to use JSP?
As per my knowledge, it is used to separate budiness logic from the view part. JSP is mainly for the front end.

But, on compilation, JSP will be converted into a servlet. Servlet is a server side component. So, what ever is written in JSP is converted into Servlet and executed at the server side......if this is true, how can we say, JSP is mainly for front end UI development?

I am confused here. Can anyone please help me why JSP is mainly used?


With Regards,
Anu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Don't confuse "front-end" with "client". JSPs and servlets execute on the server, not the client.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146
Thank you Bear Bibeault,

Considering your answer,
What is the purpose of using JSP? we can as well use servlet instead of JSP right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Building up HTML markup and complex JavaScript in Java strings in a servlet is painful, error-prone, difficult to maintain, and pretty much ridiculous. JSP allows us to write dynamic HTML pages in a much more natural fashion.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Understanding the notion of MVC can help you understand the purpose of JSP.


[My Blog]
All roads lead to JavaRanch
Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146
ok, Thank you for both of you.

I have a small question now.

what are the best practices a JSP programmer suppose to follow !! (top 3) ??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

1) Don't use scriptlets -- put no Java code in a JSP
2) Keep the JSPs as simple as possible -- hide any complexity in the controllers and beans, not on the page
3) Hide the JSPs under the WEB-INF folder to prevent direct access without their controllers
 
jQuery in Action, 2nd edition
 
subject: why to use JSP?
 
Similar Threads
executing beans on client side
difference between servlet and jsp
Server side technology?
executing beans on client side
advice needed regarding HTML and JavaScript