So, What exactly do we mean by JSP?. A JSP is a web-based powerful technology in which an html page has Java code embedded to it. It is one of the powerful technology which is implemented on server side to provide dynamic as well as static content to a client browser. It provides Java Developer and Web designer a way to execute a Java code present in a html page on the server side. Generally, the Java code embedded into an html page returns static or dynamic content upon executing on server side.
The static content can be anything from normal html page, xml or simple txt etc. The dynamic content is been generated by Java code embedded into the web-page. Both technologies are powerful and complimentary to each other. Servlets and JSP operate quite differently and even opposite at some extent. A Servlet is a simple Java program in which html is embedded.
The Java program executes on the server-side and display the result to the browser by embedding html which is output to the browser. The Servlet embed html into Java code through out.
Each JSP is first compiled into a Servlet before it can be used. When a first call is made to JSP, it translates to Java Servlet source code and then with the help of compiler it gets compiled to Java Servlet class file. This class file gets executed in the server and result are returned back to client. JSP has no such tedius task to maintain.
In a JSP page visual content and logic are seperated, which is not possible in a servlet. The dynamic part of JSP is written in Java, so it is more powerful and easier to use. MichaelT for Scripting and including Java Expressions in it. Servlets can do the same work right. There are some things that are easier in JSPs.
There are others easier in raw java servlets. Writing an application using only one of the tools is likely going to lead to poor code. MichaelT Thanks for your response Michael, Can you help me understand it better with some References if you know of or some examples. I understand that it would be easy for UI Developers to use the scripting language and use it in the expressions, but if JSP's gets converted as Servlets, what would be the advantage over it? Show 2 more comments.
Active Oldest Votes. In a servlet you would have to invert the logic, ie, write java code and print HTML. Improve this answer. Just curious is there any advantage with respect to performance in JSP than Servlets? JNL The only difference in performance is when you run a modified JSP for the first time, since it has to be converted. After that, it's a servlet as any other one.
Skip to content. Servlet should be used when there is more data processing involved whereas, JSP is generally used when there is less involvement of data processing. Servlets run faster than JSP, on the other hand JSP runs slower than servlet as it takes time to compile the program and convert into servlets.
In Servlet, you have to implement both business logic and presentation logic in the single file. Report a Bug.
Previous Prev. Next Continue. Home Testing Expand child menu Expand.
0コメント