• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why to use JSP?

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic