JSP Articles

Found 77 articles

How to write a switch statement in a JSP page?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

Following is the example of using a switch statement within a JSP page.           SWITCH...CASE Example                   The above code will generate the following result −It's Wednesday.

Read More

How to write an if-else statement in a JSP page?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 16K+ Views

The if...else block starts out as an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between the Scriptlet tags.Example           IF...ELSE Example                         Today is weekend                 Today is not weekend           The above code will generate the following result −Today is not weekend

Read More

How to delete cookies with JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

To delete cookies is very simple. If you want to delete a cookie, then you simply need to follow these three steps −Read an already existing cookie and store it in Cookie object.Set cookie age as zero using the setMaxAge() method to delete an existing cookie.Add this cookie back into the response header.Following example will show you how to delete an existing cookie named "first_name" and when you run main.jsp JSP next time, it will return null value for first_name.Example           Reading Cookies                        Reading ...

Read More

Where will be the uploaded files stored in JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 562 Views

A JSP can be used with an HTML form tag to allow users to upload files to the server. An uploaded file can be a text file or a binary or an image file or just any document.Creating a File Upload FormLet us now understand how to create a file upload form. The following HTML code creates an uploader form. Following are the important points to be noted down −The form method attribute should be set to POST method and the GET method cannot be used.The form enctype attribute should be set to multipart/form-data.The form action attribute should be set ...

Read More

How to print date and time in specific format using JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 1K+ Views

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.Let us modify the above example as follows −Example           Display Current Date & Time                        Display Current Date & Time                 Compile the above servlet once again and then call this servlet using the URL http://localhost:8080/CurrentDate. You will receive the following result −OutputDisplay Current Date & Time Mon 2010.06.21 at 10:06:44 PM GMT+04:00

Read More

Difference between Servlet and JSP

Aishwarya Naglot
Aishwarya Naglot
Updated on 14-Nov-2024 7K+ Views

Both Servlets and JSP are used in web development. The Servlets handle the logic (processing our requests and interacting with databases), and JSPs handle the presentation (displaying dynamic content on the web page). By separating the logic and presentation, our web applications become more manageable and scalable. In brief, we can think of Servlets as Java programs that run on a web server. They work as the middle layer between a request from an HTTP client (like a browser) and databases or applications on the server. When we send a request to a server, the Servlet processes that request, and ...

Read More

Difference Between JSP and PHP

Shriansh Kumar
Shriansh Kumar
Updated on 21-Jul-2023 1K+ Views

Both JSP and PHP are two popular technologies that serve to create dynamic web pages. Both are similar in the ways that they allow developers to embed code within an HTML document that can interact with databases, sessions, cookies, and other web features. However, they also have some significant differences that may affect the choice of which one to use for a web project. In this article, we will try to find the difference between JSP and PHP in terms of their syntax, performance, scalability, security, and compatibility. JSP vs PHP JSP It is an acronym that stands for Java ...

Read More

Difference between JSP and ASP

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 27-Jul-2022 5K+ Views

JSP and ASP are both server-side scripting languages. JSP is Java based and is developed by Sun Microsystems, whereas ASP is developed by Microsoft and is also referred as Classic ASP. Whenever a browser requests a JSP or ASP page, the server engine reads the file, executes the code in file and returns the HTML output to the browser.JSP is compiled, whereas ASP is interpreted. ASP.NET is a .NET based variant of ASP where the codes are compiled to improve the performance.What is ASP?ASP is a server-side scripting engine, which means the code that is written gets sent to the ...

Read More

What are advantages of using JSP?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 3K+ Views

Following table lists out the other advantages of using JSP over other technologies −vs. Active Server Pages (ASP)The advantages of JSP are twofold. First, the dynamic part is written in Java, not Visual Basic or other MS specific language, so it is more powerful and easier to use. Second, it is portable to other operating systems and non-Microsoft Web servers.vs. Pure ServletsIt is more convenient to write (and to modify!) regular HTML than to have plenty of println statements that generate the HTML.vs. Server-Side Includes (SSI)SSI is really only intended for simple inclusions, not for "real" programs that use form ...

Read More

How to setup a Web server like Tomcat to test JSP pages?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 1K+ Views

Apache Tomcat is an open source software implementation of the JavaServer Pages and Servlet technologies and can act as a standalone server for testing JSP and Servlets, and can be integrated with the Apache Web Server. Here are the steps to set up Tomcat on your machine −Download the latest version of Tomcat from https://tomcat.apache.org/.Once you downloaded the installation, unpack the binary distribution into a convenient location. For example, in C:\apache-tomcat-5.5.29 on windows, or /usr/local/apache-tomcat-5.5.29 on Linux/Unix and create CATALINA_HOME environment variable pointing to these locations.Tomcat can be started by executing the following commands on the Windows machine −%CATALINA_HOME%\bin\startup.bat ...

Read More
Showing 1–10 of 77 articles
« Prev 1 2 3 4 5 8 Next »
Advertisements