advantage of jsp

what are the advantages of jsp's except that you dont have to write html is o/p stream as in servlets? and what is the proper way to code jsp's so that our code dont get exposed to the client?

Val Dra

Ranch Hand

Posts: 439

posted 16 years ago

I don't know much about jsp yet but i know enough on asp. And if it's anything as ASP it won't get exposed because it gets executed on server side and only end result will be redirected to users browsers.

Val SCJP <BR>going for SCJD

ali farid

Ranch Hand

Posts: 60

posted 16 years ago

by client i mean if your application is hosted on the server of your company's client

Val Dra

Ranch Hand

Posts: 439

posted 16 years ago

oopss sorry i must have misunderstood.

Val SCJP <BR>going for SCJD

Stephen Peterson

Ranch Hand

Posts: 33

posted 16 years ago

You mean you want to put only the class files on the client system and not the java source files, but you can't do this because jsp files gets translated into java source file the first time it is run? Seems like it's not so much an issue, because you want to embed as little or no java code into the jsp page as possible - and put all the java business logic into beans, which can be called by the appropriate jsp tags. This makes the jsp page easier to maintain, and you can put only the class files of the javabean code on the client company's server. ------------------ United Health Group Hartford, CT, USA

United Health Group<BR>Hartford, CT, USA

faisal mahmood

Ranch Hand

Posts: 349

posted 16 years ago

First of all all JSPs' get translated to Servlets using JSP engine and then servlet classes will run. Any jsp style code will get executed in the server side and will not appear on the client side. Did you get some code which does not do the above? There should be none if the application server is according to the JSP specification. Thank you, Faisal

Bharatesh H Kakamari

Ranch Hand

Posts: 198

posted 16 years ago

There are quite many advantages of JSP over servlets. 1. Jsps have the ability of dynamic html generation. 2. As far as the performance is concerned both have the same performance. Even though when a jsp page is accessed for the first time, it takes some time for the jsp engine to compile this page to a servlet and then execute this servlet. THIS DISADVANTAGE HAS BEEN REMOVED BY PRECOMPILATION OF JSP PAGES SO THAT EVEN IF THE JSP PAGE IS ACCESSED FIRST TIME THE USER ALWAYS GETS A PRE-COMPILED PAGE. 3. The best advantage of Jsp over servlets is JSP technology separates content logic from business logic. The role of context developer is separated from component (business logic) developer. A web designer need not know java language to code servlets logic. HTH

Peter den Haan

author
Ranch Hand

Posts: 3252

posted 16 years ago

Let me make a general remark up front: in my view the main difference between JSPs and Servlets is that of emphasis. A JSP is a presentation-centered servlet. A servlet is a processing-centered JSP . The appropriate choice is dictated by the nature of the task at hand: presentation or processing.

Originally posted by Bharatesh H Kakamari:There are quite many advantages of JSP over servlets. 1. Jsps have the ability of dynamic html generation.

So have servlets, even if out.println doesn't offer much in the way of sugar coating.

2. As far as the performance is concerned both have the same performance. Even though when a jsp page is accessed for the first time, it takes some time for the jsp engine to compile this page to a servlet and then execute this servlet. THIS DISADVANTAGE HAS BEEN REMOVED BY PRECOMPILATION OF JSP PAGES SO THAT EVEN IF THE JSP PAGE IS ACCESSED FIRST TIME THE USER ALWAYS GETS A PRE-COMPILED PAGE.

But the request is always routed through the JSP container servlet which usually checks the timestamp and then forwards to the actual jsp servlet, thereby imposing a (usually insignificant) bit of overhead.

3. The best advantage of Jsp over servlets is JSP technology separates content logic from business logic. The role of context developer is separated from component (business logic) developer. A web designer need not know java language to code servlets logic.

A good developer will be as careful separating presentation from business logic in Servlets as in jsps. In fact my experience is that jsps aren't any better in encouraging good separation of responsibilities than servlets are! There's too much Java code in too many jsps and in the worst cases it deteriorates into a more unsightly mess than you can ever achieve with servlets. Having a good architecture is still too much down to disciplined development. - Peter

Raghav Mathur

Ranch Hand

Posts: 641

posted 16 years ago

jsp can be used with beans that means declaring your functions in a bean and calling them in 'n' number of jsp pages. which makes it super fast !

Raghav.

sachin sachdeva

Greenhorn

Posts: 14

posted 16 years ago

The main advantage of jsp is that it seprates the java code from HTML.Means if in the case of servlets even if u want to do some changes in HTML than that will be the resposibilty of java progrmmer because he needs to compile that file but in the case of jsp ur jsp code is seprates from HTML althoug internally it creates a servlet of that which stuff the html data in to java code.But programming point of view it becomes very very easy. and if u know ASP than JSP is very easy for u even u can go through the chapter ASP to JSP