answersLogoWhite

0

When should you use jsp and servlet in your project?

Updated: 8/16/2019
User Avatar

Wiki User

15y ago

Best Answer

JSP and servlets are used in when you are building a website that provides a server sided service, for example connecting to a database is a service. == == JSP/Servlets are java code that perform the backend operations for web pages. Such servlets run in a java container, such as JBoss or Tomcat. Where you would use these would be in a web-based environment where you wanted to run the backend on Java, as opposed to PHP, Perl, etc. As an example, eBay is run by JSP/Servlet technology. However, JSP/Servlet technology is much more complicated than scripting languages, but well worth learning.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When should you use jsp and servlet in your project?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which one is faster servlet OR jsp?

Servlet is more faster than JSP, but JSP is more convenient than Servlet and JSP is clearly superior, shorter, simple and easier to use. JSP can be perceived as Java in HTML code. JSP require no explicit compilation as like servlets and can keep in the web application server as HTML file. The web application server in turn compile the java code in JSP and load it in its library for future execution. Servlet can be perceived as HTML in Java code. The servlet is the class file, which would be loaded in the web application server as a program. The program output will be directed to the outstream object which in turn direct to the client as HTML elements.


What is the use of Servlet in java?

Java Servlet is used for Server Side programming for developing Web Applications. It easily employs Database Connectivity. We can also use JSP however it cannot replace a Java Servlet.


Why should you use PHP and not JSP?

Firstly, this is wrong question. The right one would be WHEN should you use PHP, not JSP? or, WHEN should you use PHP and WHEN JSP?


When do you use JSPs as opposed to Servlets?

JSPs and Servlets can be used interchangeably for the most part. In fact, when a JSP is compiled, it is actually turned into a servlet! That being said, there are some guidelines for using servlets over JSPs or vice versa. Here are a couple of examples, but by no means a complete list: Typically, you would use a JSP to display dynamic data, or a form. A Servlet is usually what you would want to use to process a post or a get, especially considering the method that is called when you call a servlet (either doGet or doPost). For more information on this, here is a good article on Servlet and JSP Best Practices: http:/java.sun.com/developer/technicalArticles/javaserverpages/servlets_jsp


Are you have project java have jsp plus jdbc plus swing?

No. JSP and Swings are two contrasting Technologies and cannot be used in the same application. And - JDBC can be used with both types of applications that use either JSP or Swings


Why business logic written using servlets not in jsp?

It is usually done for two reasons: 1. For security purposes - No one can see the code inside a servlet but much of the code inside a JSP can be found out by right clicking on the web page and doing a "View Source" 2. There are only one or two Servlets in any application but there may be dozens of JSP's. if you code the business logic in a JSP, then you would have to replicate the same in all the JSP's where you want this feature. Instead if you place this logic inside the servlet, it is easier for re-use. Instead of copy pasting the code in multiple places, you can place the contents in one single place.


What is JSP web language?

Java Server Page is a standard Java extension that is defined on top of the servlet Extensions. The goal of JSP is the simplified creation and management of dynamic Web pages. JSPs are secure, platform-independent, and best of all, make use of Java as a server-side scripting language.


What are jsp actions?

JSP actions are XML tags that direct the server to use existing components or control the behavior of the JSP engine. JSP Actions consist of a typical (XML-based) prefix of "jsp" followed by a colon, followed by the action name followed by one or more attribute parameters. There are six JSP Actions: < jsp : include / > < jsp : forward / > < jsp : plugin / > < jsp : usebean / > < jsp : setProperty / > < jsp : getProperty / >


What is the difference between jsp forward and response sendRedirect?

The <jsp:forward ..> is actually a call to HttpServletRequest.forward(String url) which passes the request object within the server to either a servlet or to another JSP page. The new servlet or JSP page continues to process the same request and the browser is not aware of the fact that more than one servlet or page is involved. i.e., The client is not aware that the request is being forwarded somewhere else. The URL shown in the browser stays unchanged when you do this forward. The <jsp:forward> element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file. The lines in the source JSP file after the <jsp:forward> element are not processed. The page invoked by the <jsp:forward> action has access to all the parameters in the original JSP page's request object. You can add new parameters to the request object to pass to the target page by using the <jsp:param name="..." value="..." />. Be careful when using <jsp:forward> with unbuffered output. If the JSP file has any data in the out object, using this forward action will cause an IllegalStateException to be thrown when the page is displayed. The response.sendRedirect() creates a new request object which doesn't carry any of old request information. The first request handler JSP page tells the browser to make a new request to the target servlet or JSP page. The URL shown in the browser therefore changes to the URL of the new page to which you redirect. A redirect is slower than a forward because the browser has to make a new request. Another difference is that request scope objects are no longer available after a redirect because it results in a new request. If you need to pass data to the page you redirect to, you have to use a query string and pass them as request parameters or save the data in the session or application scope objects Forward is faster than redirect but one disadvantage is that URL is not changed and also it works within the same web application. Also, when you choose to use forward, you need to think and confirm what must happen if the user reloads the page.


How many page directive can use in a single JSP?

There is no limit as such. You can use one or more Page Directives in a JSP but you cannot have duplicates


Can you use jsp as controller in struts application?

no


Can I prevent the creation of a session in a JSP page?

Yes you can. Use the below line in your JSP page to accomplish it. <%@ page session="false" %>