• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why to use JSP?

 
Anu satya
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't confuse "front-end" with "client". JSPs and servlets execute on the server, not the client.
 
Anu satya
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understanding the notion of MVC can help you understand the purpose of JSP.
 
Anu satya
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic