Found 177 Articles for JSP

How can you implement hit counter to avoid loss of count data with each restart of the application in JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

229 Views

When you restart your application, i.e., web server, this will reset your application variable and your hit counter will reset to zero. To avoid this loss, consider the following points −Define a database table with a single count, let us say hitcount. Assign a zero value to it.With every hit, read the table to get the value of hitcount.Increase the value of hitcount by one and update the table with the new value.Display the new value of hitcount as a total page hit counts.If you want to count hits for all the pages, implement above logic for all the pages.Read More

How do you implement hit counter in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

398 Views

A hit counter tells you about the number of visits on a particular page of your web site. Usually, you attach a hit counter with your index.jsp page assuming people first land on your home page.To implement a hit counter you can make use of the Application Implicit object and associated methods getAttribute() and setAttribute().This object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method.Following is the syntax to set a variable at the ... Read More

What is a hit count for a Webpage?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

638 Views

A hit counter tells you about the number of visits on a particular page of your web site. Usually, you attach a hit counter with your index.jsp page assuming people first land on your home page.To implement a hit counter you can make use of the Application Implicit object and associated methods getAttribute() and setAttribute().This object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method.Following is the syntax to set a variable at the ... Read More

What is the difference between and response.sendRedirect(url)?

Samual Sam
Updated on 30-Jul-2019 22:30:25

230 Views

The 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.sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page.

What is JSP page redirection?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

250 Views

Page redirection is generally used when a document moves to a new location and we need to send the client to this new location. This can be because of load balancing, or for simple randomization.The simplest way of redirecting a request to another page is by using sendRedirect() method of response object. Following is the signature of this method −public void response.sendRedirect(String location) throws IOExceptionThis method sends back the response to the browser along with the status code and new page location. You can also use the setStatus() and the setHeader() methods together to achieve the same redirection example −.... ... Read More

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

Samual Sam
Updated on 30-Jul-2019 22:30:25

959 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 Live Demo           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

How to print current date and time in a JSP page?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

11K+ Views

With JSP program, it is very easy to get the current date and the time. You can use a simple Date object with the toString() method to print the current date and the time as follows −Example Live Demo           Display Current Date & Time                        Display Current Date & Time                 Let us now keep the code in CurrentDate.jsp and then call this JSP using the URL http://localhost:8080/CurrentDate.jsp. You will receive the following result −OutputDisplay ... Read More

Where will be the uploaded files stored in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

381 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 can you upload a file using JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

376 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 the 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 ... Read More

How can you delete a session data in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

779 Views

When you are done with a user's session data, you have several options −Remove a particular attribute − You can call the public void removeAttribute(String name) method to delete the value associated with the particular key.Delete the whole session − You can call the public void to invalidate() method to discard an entire session.Setting Session timeout − You can call the public void setMaxInactiveInterval(int interval) method to set the timeout for a session individually.Log the user out − The servers that support servlets 2.4, you can call log out to log the client out of the Web server and invalidate ... Read More

Previous 1 ... 5 6 7 8 9 ... 18 Next
Advertisements