Found 9292 Articles for Object Oriented Programming

How to send a html based email using a JSP page?

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

492 Views

Here is an example to send an HTML email from your machine. It is assumed that your localhost is connected to the Internet and that it is capable enough to send an email. Make sure all the jar files from the Java Email API package and the JAF package are available in CLASSPATH.This example is very similar to the previous one, except that here we are using the setContent() method to set content whose second argument is "text/html" to specify that the HTML content is included in the message.Using this example, you can send as big an HTML content as ... Read More

How to send a simple text based email using a JSP page?

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

229 Views

To send an email using a JSP, you should have the JavaMail API and the Java Activation Framework (JAF) installed on your machine.You can download the latest version of JavaMail (Version 1.2) from the Java's standard website.You can download the latest version of JavaBeans Activation Framework JAF (Version 1.0.2) from the Java's standard website.Download and unzip these files, in the newly-created top-level directories. You will find a number of jar files for both the applications. You need to add the mail.jar and the activation.jar files in your CLASSPATH.Send a Simple EmailHere is an example to send a simple email from ... Read More

How do you implement the auto refresh in JSP?

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

331 Views

JSP makes this job easy by providing you a mechanism where you can make a webpage in such a way that it would refresh automatically after a given interval.The simplest way of refreshing a Webpage is by using the setIntHeader() method of the response object. Following is the signature of this method −public void setIntHeader(String header, int headerValue)This method sends back the header "Refresh" to the browser along with an integer value which indicates time interval in seconds.Auto Page Refresh ExampleIn the following example, we will use the setIntHeader() method to set Refresh header. This will help simulate a digital ... Read More

What is auto refresh feature in JSP?

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

140 Views

JSP makes this job easy by providing you a mechanism where you can make a webpage in such a way that it would refresh automatically after a given interval.The simplest way of refreshing a Webpage is by using the setIntHeader() method of the response object. Following is the signature of this method −public void setIntHeader(String header, int headerValue)This method sends back the header "Refresh" to the browser along with an integer value which indicates time interval in seconds.Auto Page Refresh ExampleIn the following example, we will use the setIntHeader() method to set Refresh header. This will help simulate a digital ... Read More

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

245 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

405 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

677 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

258 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

263 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

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 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

Advertisements