Found 9297 Articles for Object Oriented Programming

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

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

213 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

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

What are various attributes Of page directive in JSP?

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

487 Views

Following table lists out the attributes associated with the page directive −S.No.Attribute & Purpose1bufferSpecifies a buffering model for the output stream.2autoFlushControls the behavior of the servlet output buffer.3contentTypeDefines the character encoding scheme.4errorPageDefines the URL of another JSP that reports on Java unchecked runtime exceptions.5isErrorPageIndicates if this JSP page is a URL specified by another JSP page's errorPage attribute.6extendsSpecifies a superclass that the generated servlet must extend.7importSpecifies a list of packages or classes for use in the JSP as the Java import statement does for Java classes.8infoDefines a string that can be accessed with the servlet's getServletInfo() method.9isThreadSafeDefines the threading model ... Read More

What is a page directive in JSP?

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

171 Views

The page directive is used to provide instructions to the container. These instructions pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page.Following is the basic syntax of the page directive −You can write the XML equivalent of the above syntax as follows −AttributesFollowing table lists out the attributes associated with the page directive −S.No.Attribute & Purpose1bufferSpecifies a buffering model for the output stream.2autoFlushControls the behavior of the servlet output buffer.3contentTypeDefines the character encoding scheme.4errorPageDefines the URL of another JSP that ... Read More

How to handle error object in JSP using JSTL tags?

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

471 Views

You can make use of JSTL tags to write an error page ShowError.jsp with better structure and more information −           Show Error Page               Opps...                             Error:             ${pageContext.exception}                                 URI:             ${pageContext.errorData.requestURI}                             ... Read More

How to create a common error page using JSP?

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

1K+ Views

JSP gives you an option to specify Error Page for each JSP using page attribute. Whenever the page throws an exception, the JSP container automatically invokes the error page.Following is an example to specifiy an error page for a main.jsp. To set up an error page, use the directive.           Error Handling Example               We will now write one Error Handling JSP ShowError.jsp, which is given below. Notice that the error-handling page includes the directive . This directive causes the JSP compiler ... Read More

What is an exception Object in JSP? What type of exceptions can occur in a JSP page?

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

133 Views

The exception object is a wrapper containing the exception thrown from the previous page. It is typically used to generate an appropriate response to the error condition.When you are writing a JSP code, you might make coding errors which can occur at any part of the code. There may occur the following type of errors in your JSP code −Checked exceptionsA checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. ... Read More

What is the use of page object in JSP? Need an example.

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

149 Views

JSP gives you an option to specify Error Page for each JSP using page attribute. Whenever the page throws an exception, the JSP container automatically invokes the error page.Following is an example to specifiy an error page for a main.jsp. To set up an error page, use the directive.                 Error Handling Example               We will now write one Error Handling JSP ShowError.jsp, which is given below. Notice that the error-handling page includes the directive . This directive causes ... Read More

What is a page object in JSP?

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

298 Views

This object is an actual reference to the instance of the page. It can be thought of as an object that represents the entire JSP page.The page object is really a direct synonym for the this object.

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

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

13K+ 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 Live Demo           IF...ELSE Example                         Today is weekend                 Today is not weekend           The above code will generate the following result −Today is not weekend

Advertisements