Jump to content
xisto Community
tinoymalayil

Difference Between Servlet Programming And Jsp?

Recommended Posts

I don't what the difference is between Servlet programming and JSP but you can easily create JSP projects using the netbeans IDE. It creates a default package and template for you so you can quickly start developing pages. You are also able to run and test your code through the IDE too which is very handy for debugging errors. You can get netbeans at http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

Hi!

 

Both Java Servlets and Java Server Pages (JSPs) are used for developing web applications. However, the difference lies in the Java Server Pages being simpler to use for creating forms and general web interfaces while Java Servlets are better suited for tasks such as form processing and serving non-HTML content.

 

Being curious, as is human nature, you might want to know why Java Server Pages are better suited for web interfaces and Java Servlets are apt for processing data and dealing with non-HTML data, so I'll try to explain it best I can:

 

Java Servlet Pages are like PHP pages or like ASPX pages in ASP.NET. You embed your code within HTML markup such that the application server outputs the HTML markup as-is while processing the Java code written within server-side code tags. Think of server-side code tags as a specialized form of the SCRIPT tag, which is used for writing Javascript (I believe you already understand the differences between Javascript, which is a client side scripting language, and Java, which in this case is a server side scripting language).

 

Java Servlets are like C/C++ programs, where you would use the equivalent of a println statement to output data to the browser. If you want to print a few messages onto the browser, this does the job but for extensive HTML markup, you would find it difficult to output everything as a println-like statement, especially when dealing with quotes when specifying the attribute values in HTML tags.

 

To summarize, Java Server Pages are like a template processing framework (though that isn't the right term for it) while Java Servlets are like C/C++ command-line programs that can output any kind of data but is generally used for non-HTML or limited data.

 

Please feel free to write back to this thread if you have any more questions about the differences between Java Servlets and Java Server Pages (JSPs), and I or one of the other members on the forum would be more than happy to help you out with it.

 

Best Regards,

Nitin Reddy

Share this post


Link to post
Share on other sites

Ah so Java servlets are like programs just run on the application server for example apache tomcat. At the same time Java Server Pages are the same code but with additional libraries and tools designed to make developing the front end much easier? Also there is JSF I think, could you elaborate on anything about that?CheersSone

Share this post


Link to post
Share on other sites

Hi Sonesay!You've hit the nail right on the head - Java servlets are programs that run on an application server, and Apache tomcat is an example of an application server for Java servlets and Java server pages.Java Server Pages (JSPs), by themselves, do not use additional libraries, but they are interpreter differently. I wouldn't mix Java Server Pages with the tools used for building them, but what you say is true - Java Server Pages do have tools that make the development of the web front-end easier. Java Server Pages (files with the .JSP file extension, such as index.jsp) are essentially HTML files with embedded Java code that executes when the file is requested by a client (the client is usually a web browser such as Microsoft Internet Explorer, Mozilla Firefox, Google Chrome, Opera etc.). The keyword here is 'embedded'. The entire Java Server Page file does not contain Java code that can be run through the javac compiler but instead the application server would do the job of finding the embedded Java code on the Java Server Page and compiling it (this is an over-simplified explanation of what really goes on within the application server).Java Server Faces is another framework that builds upon the benefits of Java Server Pages. You can think of it as a framework providing self-contained user interface components that are analogous to the ASP.NET server controls provided by the Microsoft ASP.NET framework. PHP has an equivalent called the Yii framework, formerly called the Prado framework.Regards,Nitin Reddy

Share this post


Link to post
Share on other sites
difference of jsp and servlet Difference Between Servlet Programming And Jsp?

show by program which give the difference between jsp page and servlet.Which is easy understoodable.

-reply by NAIYYAR ALI

Share this post


Link to post
Share on other sites
Mobile to Servlet via URLDifference Between Servlet Programming And Jsp?

Hi Nitin Reddy

This is Soumya Maitra. I am new to java. May be my question is little fuzzy to you, please pardon me for that.

I have come to know that j2me can also talk JSP or a servlet to get some database stored information. And I have developed an application that can talk to a servlet too. But my question is how can I make sure that the connection is secure that is unreadable by a hacker? Can you suggest me urls where I can read steps to secure my Mobile to server connection?

-reply by Soumya Maitra

Share this post


Link to post
Share on other sites

tinoymalayil,In earlier days, programmer used to put programming logic and presentation logic in a single file called Servlet. Those are still good for small applications. but this days, the applications are more separated in Presentation and programming so, they separated Presentation logic and put into JSP. JSP are more like HTML where you specify the layout. And then webserver will convert it into the servletFor start, you can simply develop a HTML page and rename it as JSP and it will work. Then you can explore some new jsp tags with trial and error. Drop me a mail if you need any help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.