Found 9326 Articles for Object Oriented Programming

How to refresh a JSP page at regular interval?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

258 Views

Following example would use setIntHeader() method to set Refresh header to simulate a digital clock −           Auto Refresh Header Example                        Auto Refresh Header Example                 Now put the above code in main.jsp and try to access it. This will display the current system time after every 5 seconds as follows. Run the JSP. You will receive the following output: −Auto Refresh Header ExampleCurrent Time is: 9:44:50 PM

What is isErrorPage attribute in JSP?

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

1K+ Views

The errorPage attribute tells the JSP engine which page to display if there is an error while the current page runs. The value of the errorPage attribute is a relative URL.The following directive displays MyErrorPage.jsp when all uncaught exceptions are thrown −The isErrorPage attribute indicates that the current JSP can be used as the error page for another JSP.The value of isErrorPage is either true or false. The default value of the isErrorPage attribute is false.For example, the handleError.jsp sets the isErrorPage option to true because it is supposed to handle errors −

What are important server response headers that are useful in web programming?

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

121 Views

Following is a summary of the most useful HTTP 1.1 response headers which go back to the browser from the web server. These headers are frequently used in web programming −Sr.No.Header & Description1AllowThis header specifies the request methods (GET, POST, etc.) that the server supports.2Cache-ControlThis header specifies the circumstances in which the response document can safely be cached. It can have values public, private or no-cache etc. Public means document is cacheable, Private means document is for a single user and can only be stored in private (nonshared) caches and no-cache means document should never be cached.3ConnectionThis header instructs the ... Read More

What is errorPage attribute in JSP?

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

480 Views

The errorPage attribute tells the JSP engine which page to display if there is an error while the current page runs. The value of the errorPage attribute is a relative URL.The following directive displays MyErrorPage.jsp when all uncaught exceptions are thrown −The isErrorPage attribute indicates that the current JSP can be used as the error page for another JSP.The value of isErrorPage is either true or false. The default value of the isErrorPage attribute is false.For example, handleError.jsp sets the isErrorPage option to true because it is supposed to handle errors −

How to read a HTTP header using JSP?

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

2K+ Views

Following is the example which uses getHeaderNames() method of HttpServletRequest to read the HTTP header information. This method returns an Enumeration that contains the header information associated with the current HTTP request.Once we have an Enumeration, we can loop down the Enumeration in the standard manner. We will use the hasMoreElements() method to determine when to stop and the nextElement() method to get the name of each parameter name.           HTTP Header Request Example                        HTTP Header Request Example         ... Read More

What is contentType attribute in JSP?

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

4K+ Views

The contentType attribute sets the character encoding for the JSP page and for the generated response page. The default content type is text/html, which is the standard content type for HTML pages.If you want to write out XML from your JSP, use the following page directive −The following statement directs the browser to render the generated page as HTML −The following directive sets the content type as a Microsoft Word document −You can also specify the character encoding for the response. For example, if you wanted to specify that the resulting page that is returned to the browser uses ISO ... Read More

What is autoFlush attribute in JSP?

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

1K+ Views

The autoFlush attribute specifies whether the buffered output should be flushed automatically when the buffer is filled, or whether an exception should be raised to indicate the buffer overflow.A value of true (default) indicates automatic buffer flushing and a value of false throws an exception.The following directive causes the servlet to throw an exception when the servlet's output buffer is full −This directive causes the servlet to flush the output buffer when full −Usually, the buffer and the autoFlush attributes are coded on a single page directive as follows −

What happens when buffer is set to a value "none" in JSP?

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

146 Views

The buffer attribute specifies the buffering characteristics for the server output response object.You may code value of "none" to specify no buffering so that the servlet output is immediately directed to the response object or you may code a maximum buffer size in kilobytes, which directs the servlet to write to the buffer before writing to the response object.To direct the servlet to write the output directly to the response output object, use the following −

Can we write code in try/catch block in JSP as well?

George John
Updated on 30-Jul-2019 22:30:25

206 Views

If you want to handle errors within the same page and want to take some action instead of firing an error page, you can make use of the try....catch block.Following is a simple example which shows how to use the try...catch block. Let us put the following code in main.jsp −           Try...Catch Example                   Access the main.jsp, it should generate an output somewhat like the following −An exception occurred: / by zero

What is a buffer attribute in JSP?

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

734 Views

The buffer attribute specifies the buffering characteristics for the server output response object.You may code a value of "none" to specify no buffering so that the servlet output is immediately directed to the response object or you may code a maximum buffer size in kilobytes, which directs the servlet to write to the buffer before writing to the response object.To direct the servlet to write the output directly to the response output object, use the following −Use the following to direct the servlet to write the output to a buffer of size not less than 8 kilobytes −

Advertisements