Object Oriented Programming Articles

Page 559 of 589

I need to understand how to use a bean and update its properties in JSP page. Please share an example.

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 768 Views

The useBean action is quite versatile. It first searches for an existing object utilizing the id and scope variables. If an object is not found, it then tries to create the specified object.The simplest way to load a bean is as follows −Once a bean class is loaded, you can use jsp:setProperty and jsp:getProperty actions to modify and retrieve the bean properties.Following table lists out the attributes associated with the useBean action −S.No.Attribute & Description1classDesignates the full package name of the bean.2typeSpecifies the type of the variable that will refer to the object.3beanNameGives the name of the bean as specified ...

Read More

What is the use of jsp text action element?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 208 Views

The action can be used to write the template text in JSP pages and documents. Following is the simple syntax for this action −Template dataThe body of the template cannot contain other elements; it can only contain text and EL expressions (Note − EL expressions are explained in a subsequent chapter). Note that in XML files, you cannot use expressions such as ${whatever > 0}, because the greater than signs are illegal. Instead, use the gt form, such as ${whatever gt 0} or an alternative is to embed the value in a CDATA section.]]>If you need to include a ...

Read More

How to write a for loop in a JSP page?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 7K+ Views

Following is the for loop example − FOR LOOP Example JSP Tutorial The above code will generate the following result −JSP Tutorial JSP Tutorial JSP Tutorial

Read More

What is the use of Cookie or hidden fields in JSP?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 675 Views

CookiesA webserver can assign a unique session ID as a cookie to each web client and for subsequent requests from the client they can be recognized using the received cookie.This may not be an effective way as the browser at times does not support a cookie. It is not recommended to use this procedure to maintain the sessions.Hidden Form FieldsA web server can send a hidden HTML form field along with a unique session ID as follows −This entry means that, when the form is submitted, the specified name and value are automatically included in the GET or the POST ...

Read More

How can we maintain session between Web Client and Web Server?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 2K+ Views

Following are the few options to maintain the session between the Web Client and the Web Server −CookiesA webserver can assign a unique session ID as a cookie to each web client and for subsequent requests from the client they can be recognized using the received cookie.This may not be an effective way as the browser at times does not support a cookie. It is not recommended to use this procedure to maintain the sessions.Hidden Form FieldsA web server can send a hidden HTML form field along with a unique session ID as follows −This entry means that, when the ...

Read More

Which methods can be used to read HTTP header in your JSP program.

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 481 Views

The request object provides methods to get HTTP header information including form data, cookies, HTTP methods, etc.Following table lists out the important methods that can be used to read HTTP header in your JSP program. These methods are available with HttpServletRequest object which represents client request to webserver.Sr.No.Method & Description1Cookie[] getCookies()Returns an array containing all of the Cookie objects the client sent with this request.2Enumeration getAttributeNames()Returns an Enumeration containing the names of the attributes available to this request.3Enumeration getHeaderNames()Returns an enumeration of all the header names this request contains.4Enumeration getParameterNames()Returns an enumeration of String objects containing the names of the ...

Read More

What methods of session object is used frequently in JSP and for what purpose?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 310 Views

Here is a summary of important methods available through the session object −Sr.No.Method & Description1public Object getAttribute(String name)This method returns the object bound with the specified name in this session, or null if no object is bound under the name.2public Enumeration getAttributeNames()This method returns an Enumeration of String objects containing the names of all the objects bound to this session.3public long getCreationTime()This method returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.4public String getId()This method returns a string containing the unique identifier assigned to this session.5public long getLastAccessedTime()This method returns the last ...

Read More

How to delete Session data in JSP?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 4K+ 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 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 logout to log the client out of the Web server and invalidate all sessions ...

Read More

Please share a working example of session maintenance in JSP.

George John
George John
Updated on 30-Jul-2019 374 Views

This example describes how to use the HttpSession object to find out the creation time and the last-accessed time for a session. We would associate a new session with the request if one does not already exist.           Session Tracking                   Session Tracking                         Session info          Value     ...

Read More

What is a config Object in JSP?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 476 Views

The config object is an instantiation of javax.servlet.ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet.This object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file locations etc.The following config method is the only one you might ever use, and its usage is trivial −config.getServletName();This returns the servlet name, which is the string contained in the element defined in the WEB-INF\web.xml file.

Read More
Showing 5581–5590 of 5,881 articles
« Prev 1 557 558 559 560 561 589 Next »
Advertisements