Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

servlet

Posted on 2005-05-17
8
Medium Priority
?
381 Views
Last Modified: 2010-04-01
what is the difference between jsp and servlet, or is there a comparision at all?




Moiz
0
Comment
Question by:Moizsaif123
8 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 14019728
A jsp is compiled into a servlet that (by default) returns HTML

You can change this of course...
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14019742
So basically, a JSP is the same as a servlet with a doGet method which has text/html as it's responseType

With a servlet, you can do doPost too :-) (as well as others)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14019764
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Overview.html

Added to that list is the fact that there are now hundreds of tag-libraries you can plug in to JSPs (or write your own)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Author Comment

by:Moizsaif123
ID: 14019815
when it says...

Building Web pages on the fly is useful ....for e-commerce sites do this as well.


building webpages on the fly means..they refresh on a timer basis and update records?

what do e-commerce sites usually do?


Moiz


0
 
LVL 35

Expert Comment

by:TimYates
ID: 14019877
No, the page has current (up to date) data on it is what they mean...  they are talking about dynamic pages as a whole (both jsp and servlet allow you to do this, as does ASP, CGI, etc)

That link is a bit rubbish...sorry :-(
0
 
LVL 2

Expert Comment

by:patbin
ID: 14025198
a JSP is a Servlet that thinks it's a Web page.

 Both use server-side Java to dynamically generate web pages. The source code to a JSP looks like HTML, with Java embedded inside funny tags (*); the source code to a servlet looks like Java, with HTML embedded in out.print(...) statements. Both use the Servlet API to communicate with the web server and the client. In fact, a JSP gets compiled into a servlet, so they're almost identical in terms of expressive power. The choice is, whether you're more comfortable coding your pages in Java or in JSP-style HTML; and since you can call a JSP from a Servlet and vice versa, you don't have to make an either-or decision.
0
 
LVL 16

Assisted Solution

by:gnoon
gnoon earned 200 total points
ID: 14025332
As other experts said ...

JSP is high-level language of Servlet.

If you're writing web by JSP, you'll get *.jsp files, but you'll get *.java files if you're writing by Servlet.
However, the final of both .jsp and .java is .class file by transform process

   file.jsp ----> file.java ----> file.class

This process is done by web container, e.g. Tomcat, JBoss, Websphere etc.

The .class file will provide code (called "Business Logic") for generating a web page (HTML, XML, JavaScript, VbScript etc) in various format depends on some parameters. Whenever a client make a request to a .class (by refer to a servlet or a jsp file), the web container will executes the code in the file .class to generate a web page for the request. This process is called "building webpage on the fly". In another word, you're not writing web pages directly, but you're writing a tool to generate web pages using java language.

This useful for e-commerce sites because most of e-commerce sites are saling products and services on sites.
You can remember which products are selected by user and show only those selected instead of all products to user.
Not only that, you can compute total price and show pictures of those products by get images from your database.
Of course, I would use all of my life to explain all benefits that JSP and Servlet can be applied to :)

Finally, I would like to say that

By JSP, you're writing java language inside HTML file.
By Servlet, you're writing  HTML language inside JAVA file.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14025532
>> By JSP, you're writing java language inside HTML file.
>> By Servlet, you're writing  HTML language inside JAVA file.

Unless of course, you're handling binary data, like generating an image on the fly...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Moore’s Law has proven itself time and time again since it was first introduced. So what’s next? Will Moore’s law continue to remain relevant, or will new technology take over and bring us the next big advancement in computing?
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question