Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: how to access pageContext inside a function declared in jsp


Message #1 by "vinodbonde" <vinodbonde@h...> on Thu, 13 Mar 2003 07:14:56
I want to access the pageContext object inside the function that is 
declared in the jsp page in the static block 
I am getting a null pointer exception in this case 
Why? the reason i am not getting 
Is it not possible to do so
thanks
vinod

The code is
 ===============
<jsp:useBean id="testbean" class="test.TestBean" scope="page" />
<%@page import="javax.mail.Session"%>
<%!
	public synchronized void  addFirst(){
		 
		test.TestBean testbean = (test.TestBean)
pageContext.findAttribute("testbean");
		for(int i=0;i<1000000000;i++);
		for(int i=0;i<1000000000;i++);
		System.out.println("testbean  >"+testbean);
		for(int j=0; j<1000; j++){
			testbean.iClass = testbean.iClass + 1;
		}
	}
%>
 
<%	
	test.TestBean tb = new test.TestBean();
	out.println("Below is output of a method from included  page<br>");
	addFirst();
	out.println("<a href=next1.jsp>next</a>");
	out.println("iclass = "+testbean.iClass);
%>

  Return to Index