Link to home
Start Free TrialLog in
Avatar of Moiz Saifuddin
Moiz Saifuddin

asked on

servlet

what is the difference between jsp and servlet, or is there a comparision at all?




Moiz
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
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)
Avatar of Moiz Saifuddin
Moiz Saifuddin

ASKER

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


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 :-(
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> 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...