Home Jsp removeAttribute() Method Of The Request Object



removeAttribute() Method Of The Request Object
Posted on: February 9, 2008 at 12:00 AM
This section introduces for the method removeAttribute() of the request object.

removeAttribute() Method Of The Request Object

     

This section introduces for the method removeAttribute() of the request object. This method removes the attribute. This method takes a string type parameter i.e. the attribute name that has to be removed. After applying this method you can't access the attribute. If you specify the method for getting the value of the attribute what has removed, you will get the null value.

In this section, you will see more about the removeAttribute() method of the request object in JSP by learning through the provided description and the JSP code of the example. You can understand very efficiently the JSP code of the example.

Here is the JSP code of the RemoveAttributeMethod.jsp file:

<%
	request.setAttribute("UName", "chandan");
	request.setAttribute("Password", "chand");
	String pageName = "RemoveAttributeMethod1.jsp";
	RequestDispatcher requestDispatcher = request.getRequestDispatcher
(pageName);
	if(requestDispatcher != null){
		requestDispatcher.forward(request, response);
	}
%>

Here is the JSP code of the RemoveAttributeMethod1.jsp file:

<b>
<%
	out.println("User Name: " + request.getAttribute("UName") + "<br/>");
	out.println("Password: " + request.getAttribute("Password") + "<br/>");
	request.removeAttribute("Password");
	out.println("Your name: " + request.getAttribute("UName") + "<br/>");
	out.println("Your password: ");
	if(request.getAttribute("Password") == null)
		out.println("\'Password\' attribute is removed.");
	else
		out.println(request.getAttribute("Password"));
%></b>

Output for the both examples:

Download the RemoveAttributeMethod.jsp file.

Download the RemoveAttributeMethod1.jsp file.

Related Tags for removeAttribute() Method Of The Request Object:
cstringnullmethodgettyperemovevalueparameternameattributethisappmoveiffortoramcieilcanulpeapplyceinasmpartrcaafteresspecemmeppparamsspessatplykishallmeterarccstrvattssriringthstaccessapaluafhatplmovo


More Tutorials from this section

Ask Questions?    Discuss: removeAttribute() Method Of The Request Object   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.