When a JSP include directive is used, the included file's code is added into the added JSP page at page
translation time, this happens before the JSP page is translated into a servlet. While if any page is included
using action tag, the page's output is returned back to the added page. This happens at runtime
Posted Date:- 2021-08-18 11:28:37
Use the following ways to pass control of a request from one servlet to another or one jsp to another.
The RequestDispatcher object ‘s forward method to pass the control.
The response.sendRedirect method
Posted Date:- 2021-08-18 11:26:57
Give a sample JSP configuration in the deployment descriptor.
1. Management of scriptlet elements on the page,
2. Controlling the execution of expressions in a language
3. URL pattern definition for encoding,
4. Determining the size of the buffer that is used for objects on the page
5. Identification of resource groups corresponding to a URL pattern to be processed as an XML document.
Posted Date:- 2021-08-18 11:24:28
You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done
by adding the directive <%@ page isThreadSafe="false" % > within your JSP page.
Posted Date:- 2021-08-18 11:20:33
jsplnit(): Initially, the method is called to initialize servlet and is called only for once.
_jspService(): The container calls this method and then processes the request accordingly.
jspDestroy(): Before the demolition of instance, this method is called.
Posted Date:- 2021-08-18 11:17:16
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object including PreparedStatement and CallableStatement objects, or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object.
Posted Date:- 2021-08-18 11:16:05
It is possible to make the Finally Clause to not to fail by using System.exit(1); in the try block.
Posted Date:- 2021-08-18 11:15:14
JSP is preferred for creating web-based client program. Because no plug-ins/security policy files are needed on the client systems whereas applet does. Also, JSP pages enable cleaner and more module application design because they provide a way to separate applications programming from web page design. This means personnel involved in web page design do not need to understand Java programming language syntax to do their jobs.
Posted Date:- 2021-08-18 11:14:19
Deleting the Session Data involves the following steps.
1. Remove a particular attribute: public void removeAttribute(String name) method is called to delete the value associated with the particular key.
2. Delete the whole session: public void invalidate() method is called to discard an entire session.
3. Setting the Session timeout: public void setMaxInactiveInterval(int interval) method is called to set the timeout for a session individually.
4. Log the user out: The logout is called to log the client out of the Web server and invalidate all sessions belonging to all the users.
5. web.xml Configuration: In Tomcat, using the above-mentioned methods, one can configure session time out in web.xml file as follows.
Posted Date:- 2021-08-18 11:13:29
Setting cookies with JSP involves the following steps:
1. Creating a Cookie object: Cookie constructor is called with a cookie name and a cookie value, both are strings.
2. Setting the maximum age: setMaxAge is used to specify the length of the cookie(in seconds) should be valid.
3. Sending the cookie into the HTTP response headers: response.addCookie is used to add cookies in the HTTP response header.
Posted Date:- 2021-08-18 11:09:53
You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically
forwarded to an error processing page.
For example:
redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request
processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive:
the Throwable object describing the exception may be accessed within the error page via the exception implicit
Posted Date:- 2021-08-18 11:07:47
Some of the Major Advantages of JSP over Pure Servlets are as discussed below:
It is more convenient to write and modify normal HTML than to have plenty of println statements that generate the HTML.
Embedding of Java code in HTML pages.
Platform independence.
Creation of database-driven Web applications.
Server-side programming capabilities.
Posted Date:- 2021-08-18 11:06:42
We have 4 scope objects.
These are useful carry the information from .jsp file to another .jsp file.
? page
? request
? application (context)
? session
In the all scope objects application scope object having highest accessibility that means we can use that scope object information from all browser as well windows also.
Session scope object data can be accessible within the same browser but all windows.
Request scope object data can be accessible only one window, once response handover to browser request scope object data will be destroyed.
Page scope object data can be accessible only within the same page.
Posted Date:- 2021-08-18 11:05:49
The advantages of JSP over ASP are as follows:
The dynamic part of the code is written in Java, not in Visual Basic or the Microsoft-specific language. Hence, it is powerful and easier to use.
It is portable to other operating systems and Non-Microsoft Web servers.
Posted Date:- 2021-08-18 11:03:58
You cannot override the _jspService() method within a JSP page. You can however, override the jspInit() and
jspDestroy() methods within a JSP page. jspInit() can be useful for allocating resources like database
connections, network connections, and so forth for the JSP page. It is good programming practice to free any
allocated resources within jspDestroy().
The jspInit() and jspDestroy() methods are each executed just once during the lifecycle of a JSP page and are
typically declared as JSP declarations.
Posted Date:- 2021-08-18 11:02:22
JSP includes directives that are used to deploy static files in JSP. In this way, the inclusion process is performed only once as the resources are included, but before that, the URL must be given for file.
Posted Date:- 2021-08-18 11:01:11
There are five tags available in JSTL
1. Core tags
2. Function tags
3. SQL tags
4. XML tags
5. Internationalization tags
Posted Date:- 2021-08-18 11:00:26
It is a JSP library that has predefined tags and soothes the process of developing JavaServlet Page.
Posted Date:- 2021-08-18 10:59:00
The object cloning is a process of creating an exact copy of the existing object. The clone() method of Object class is used to create the clone an existing object. The class, whose object the user tries to clone is expected to implement the java.lang.Cloneable interface. If it does not implement the Cloneable interface, then the clone() method generates the CloneNotSupportedException.
1. protected Object clone() throws CloneNotSupportedException
Posted Date:- 2021-08-18 10:58:31
The Client-Side validation is done using JavaScript. The validation takes place within the browser. Javascript is used to submit the data in the form when the validation is successful. Validation errors do not require any extra network trip because the form cannot be submitted if there are any errors.
Posted Date:- 2021-08-18 10:57:19
Yes, We can use a constructor in place of init() method. But it is not preferred because init() was developed because earlier Java versions could not invoke constructors with arguments dynamically. So they could not assign a servletConfig. However, servlet containers still call an only no-arg constructor. So there is no access to servletContext or servletConfig.
Posted Date:- 2021-08-18 10:45:31
We can stop errors in display in a JSP Page by setting up an “ErrorPage†attribute of the PAGE directory to the name of the error page in the JSP page, and then in the error JSP page set “isErrorpage=â€TRUEâ€.
Posted Date:- 2021-08-18 10:44:59
Static pages can be included in a JSP using the include directive. This way the inclusion is performed in the translation phase once. Note that a relative URL must be supplied for file attribute. Although static resources may be included, it is not preferred as each request requires inclusion.
Posted Date:- 2021-08-18 10:44:29
The Web Container creates certain objects that include the information related to a particular Request, Application or a Page. These Objects are called as Implicit Objects. The Implicit Objects in the JSP are as follows:
Posted Date:- 2021-08-18 10:35:40
You can use a client-side Refresh or Server Push.
Posted Date:- 2021-08-18 10:35:09
YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated
in tag libraries.
Posted Date:- 2021-08-18 10:30:21
JSP pages the preferred API for creating a web-based client program because no plug-ins or security policy files are needed on the client systems(applet does). Also, JSP pages
enable cleaner and more module application design because they provide a way to separate applications
programming from web page design. This means personnel involved in web page design do not need to
understand Java programming language syntax to do their jobs.
Posted Date:- 2021-08-18 10:29:48
Implicit objects are objects that are created by the web container and contain information related to a particular
request, page, or application. They are:
--request
--response
Saikat Banerjee Page 2
--pageContext
--session
--application
--out
--config
--page
--exception
Posted Date:- 2021-08-18 10:28:36
The Three tags used in the JSP Bean development are as follows:
jsp:useBean
jsp:setProperty
jsp:getProperty
Posted Date:- 2021-08-18 10:27:15
Custom Tags in JSP are created using the following steps.
1.Creating the Tag Handler Class
2.Creating the TLD File
3.Creating the JSP File
Creating the Tag Handler Class:
To create a Tag Handler Class, we need to inherit the TagSupport Class and then override doStartTag() method. To write the data for JSP, we need to use the JspWriter class. The PageContext class provides getOut() method which returns the instance of the JspWriter class. Later, the TagSupport class provides an instance of pageContext by default.
Creating the TLD File:
TLD stands for Tag Library Descriptor file. It contains the information related to the tag and Tag Hander classes. It must be held inside the WEB-INF directory.
Creating the JSP File:
We will be specifying the path of the TLD file directly. It is recommended to use the URI name instead of full a path of the TLD file. It uses taglib directive to use the tags defined in the TLD file.
Posted Date:- 2021-08-18 10:24:48
1. Boolean
2. Integer
3. Floating point
4. Null
5. String
Posted Date:- 2021-08-18 10:23:26
To forward the JSP servlet request, one can use the “forward†tag before that one needs to send the URL pattern of the servlet.
Posted Date:- 2021-08-18 10:22:34
Below is the list of few attributes of the JSP page directive briefly explained.
1. Import attribute:- Used to guide containers to import java classes and interfaces and produce servlet side by side. It is also one of the most used attributes.
2. Extends attribute:- It defines the superclass produced by servlet code, and it can be used when one has expanded HttpServlet.
Posted Date:- 2021-08-18 10:20:01
JSP page directives apply to the whole page and offer a number of attributes in one single page. It is also possible to have numerous page directives applied to a single JSP page.
Posted Date:- 2021-08-18 10:19:01
Custom Tags in JSP are created using the following steps.
1. Creating the Tag Handler Class
2. Creating the TLD File
3. Creating the JSP File
Posted Date:- 2021-08-18 10:18:18
The objects which are created or given by the container to implement our jsp logic are called Implicit Objects.
We have 9 implicit objects.
1. config
2. session
3. application(context)
4. pageContext
5. out
6. page
7. exception
8. request
9. response
Posted Date:- 2021-08-18 10:16:52
The major difference between ServletContect and PageContext is, the ServletContext is designed to provide information about the Container and on the other hand, the PageContext is designed to provide information about the Request.
Posted Date:- 2021-08-18 10:10:30
The Literals used in JSP are as follows:
Null
Boolean
String
Integer
Float
Posted Date:- 2021-08-18 10:09:15
The JSP implicit objects are established by the servlet while converting JSP to the servlet container. Nine JSP implicit objects can be used in a JSP page directly. Two implicit items are part of the _jspService() method argument. Seven out of nine implicit objects are asserted as a local variable of _jspService().
Posted Date:- 2021-08-18 10:07:53
As the name hints, the JSP declarations are chiefly utilized to declare methods and class variables on a JSP page. At the same time, it is significant to keep in mind the exceptions to the application of the same. Declarations are not included in the service method when a JSP is translated to a servlet.
Posted Date:- 2021-08-18 10:06:41
It is useful for writing the code within the _jspService(.........,.........). It is useful for declaring local variables, final variables, method calling statements, doing operations (logic).We can write one or more statements and every statement ended with semicolon.
Posted Date:- 2021-08-18 10:05:39
This tag is useful writing code/programming elements at class level.
The programming elements may be blocks, constructors, variables, methods.
The code is always added to our class outside of the _jspService(-,-).
We can write multiple statements within the single declaration tag.
Every statement should be ended with semicolon.
Syntax: <%! ————– %>
Posted Date:- 2021-08-18 10:04:16
Include directive and include action, as the name suggests, is the method used to include the result of some other page to the required destination.
Posted Date:- 2021-08-18 10:02:16
The dynamic part of JSP is written in java and hence proves to be easier and powerful. It can effortlessly port itself to any operating system.
Posted Date:- 2021-08-18 10:01:58
There are three types of comments we can use in JSP.
1. HTML comment <!– comment text –>
This tag is not ignored by the JSP container, this tag will be placed into Page Implementation class (PIC), handover to browser by Servlet container, but browser will ignores.
2. JSP comment <%– comment text –%>
This tag is ignored by the Jsp Container
3. Java comment: If we are writing java comments outside of html comment and jsp comment these comments will be treated as html code.
If we are writing java comments in declarative and scriptlet tag these comments not ignored by the jsp container these comments are placed into PIC in translation phase, but in compilation jsp container ignores.
Posted Date:- 2021-08-18 10:01:35
We have 5 types of tags in JSP.
1. Scripting tags
2. Directive tags.
3. Standard action tags
4. Custom action tags
5. JSTL
Posted Date:- 2021-08-18 10:00:41
The JSP text files combine all the available files of HTML, XML code, and elements and the previously rooted java code.
Posted Date:- 2021-08-18 09:59:22
The JavaServer page is the java servlet that acts as the user interface for java based applications.
Posted Date:- 2021-08-18 09:58:58
The JSP tags generally start with <% and end with %>
Posted Date:- 2021-08-18 09:58:37
JavaServer Pages is a technology employed to develop web pages that aid dynamic content. It is a server-side programming language exploited by developers to insert java code in HTML files.
Posted Date:- 2021-08-18 09:58:17