answersLogoWhite

0


Best Answer

Yes. They are both used almost always together. In fact JSPs get converted to Servlets at the time of execution

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

7mo ago

Yes, JSP (JavaServer Pages) and Servlets can be used together in a web application. Servlets handle the business logic and processing of requests, while JSP is used to create the user interface and generate dynamic content. Servlets can interact with JSP pages to pass data and control the flow of the application.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you use jsp and servlets together?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Information Science

What are the advantages and disadvantages of JSP?

Advantages of JSP 1. HTML friendly simple and easy language and tags. 2. Supports Java Code. 3. Supports standard Web site development tools. Disadvantages of JSP 1. As JSP pages are translated to servlets and compiled, it is difficult to trace errors occurred in JSP pages. 2. JSP pages require double the disk space to hold the JSP page. 3. JSP pages require more time when accessed for the first time as they are to be compiled on the server.


How do you create an address book using jsp and store all the information?

To create an address book using JSP, you can create a form to input contact information like name, email, phone number, etc. When the form is submitted, you can handle the data in a servlet and store it in a database like MySQL using JDBC. Then, you can retrieve and display this information in the JSP using Java servlets.


How do you dynamically identify the jsp in servlet?

You can dynamically identify the JSP file in a servlet by using the request URL or request parameters to determine which JSP to forward the request to. You can also store necessary information in session attributes or external configurations to help determine the appropriate JSP to display. Finally, you can use a servlet mapping or URL pattern to route requests to different JSP files based on the URL.


What is servlet context?

The ServletContext is an object provided by the servlet container that allows servlets to communicate with the container. It represents the configuration and environment of a web application and provides access to resources such as parameters, attributes, and initialization parameters. Servlets can use the ServletContext to perform tasks like accessing resources, logging events, and managing session persistence.


Set and get session attributes syntax in servlets and java script?

Setting and getting session attributes is fairly easy. It is the same in both Servlets and JSPs with one exception. In a JSP, you already have access to the session object, and you do not have to declare it. In a Servlet, you must get the session like this: javax.servlet.http.HttpSession session = request.getSession(); Once you have done that, you can set a session object like this: session.setAttribute("name","value"); To retrieve the value, do this: String foo = (String) session.getAttribute("name"); A couple of things to keep in mind: * The second parameter in the setAttribute method is an Object, not a String. When you retrieve the value, you have to cast it. In the example above, I am casting it to a String. * If you try to perform a getAttribute on a session attribute that does not exist, or was not set, it will return a null. * Session attributes are not available using JavaScript. You can not set or get an attribute in JavaScript. * You do NOT need to do the 'session = request.getSession() in a JSP. It is only necessary in a Servlet.

Related questions

Can you create web forums using jsp and servlets?

Yes. All sorts of web Applications/websites can be created using JSP and Servlets


How you can display servlet page in jsp page?

You cannot. You display JSP Pages using the help of Servlets. Servlets are of the background classes and you cannot display them


Is it mandatory to learn servlets before JSP?

No. But, knowledge of Servlets would be an added advantage if you are learning JSPs


Create a table using JSP Servlets?

scope of operater


When should you use jsp and servlet in your project?

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.


What is the latest version of servlet specification?

Servlets 3.0 and JSP 2.1


How do you proove servlets are faster than JSP?

because JSP internally changes in servlet and then follow servlet life cycle, so it is slower than servlet


Is it necessary to learn advanced java for JSP?

It is a good to know item. It is not mandatory or necessary. Basic knowledge of core Java is enough to learn JSP and Servlets.


What has the author Andrea Steelman written?

Andrea Steelman has written: 'Murach's Java servlets and JSP' -- subject(s): Java (Computer program language), JavaServer pages, Servlets


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


What is difference between servlets and java server pages?

SERVLETS JSP 1. Servlet is a java class. 2. Servlet is a single instance multiple thread web application, In which HTML code can be included in java code. 3. In servlets the presentation logic and the B.logic is tightly coupled. 4. For every modification done in servlet program, we need to recompile and reload the application. 5. In servlets implicit objects are not available. 6. Servlets are supported to HTTP, FTP, and SMTP protocols. 7. Sevlets are need Deployment Descriptor file (web.xml) 1. Jsp is a file. 2. In jsp java code can be included in HTML code by using special tags. 3. In jsp's the presentation logic and B.logic are separated by defining the java beans. 4. If any modifications done in jsp's without recompiling and reloading , the modifications are reflected. 5. In jsp's implicit objects are available which is we can implement directly into jsp pages. 6. Jsp are supported to HTTP protocol only. 7. No need of Deployment Descriptor file (web.xml) rajus_1219@yahoo.co.in


How can you learn Servlets and Jsps in an easy way?

Try the Head First JSP & Servlets book. It is a good book for learning them. You can also try the internet. You can get a lot of websites that give you tutorials on JSPs and Servlets. One of them is available in the related links section