aspose file tools*
The moose likes Servlets and the fly likes Session Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Problem" Watch "Session Problem" New topic
Author

Session Problem

Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
Hi

I know this topic is been discused here a lot . But i have an error thrown so thought if any one would help

I have a method where we set the session variable
public void update(Observable o, Object arg)
{

super.update(o,arg);
Datagrid m_newdatagrid1 = (Datagrid)getControl(CONTROL_GRID, Datagrid.class);
DataProvider dp = (DataProvider)m_newdatagrid1.getDataProvider();
getPageContext().getSession().setAttribute("dap",dp);

}

Now i am retreiving the session in other method in same class

public void writefile1(HttpServletResponse response, JspWriter out)throws IOException, DfException
DataProvider w_dp = null;

try
{
w_dp = (DataProvider) SessionState.getAttribute("dap");
}
catch (NullPointerException e )
{System.out.println("The Session is Not set" + e);
}

Q) IT THROWS ME NULL POINTER EXCEPTION

can someone help please
Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
please help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

Please read this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
Hi Raj
Okay i have read your problem. You mean to say your setting some value in session and when u try to access it, you get null back. Okay is the code you have given in the forum in servlets/jsp/utility class. Morever what is "SessionState". can you provide more info so that i can help. Please give a small background of your requirement.

Regards
Makarand Parab
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
Hi Raj
One more thing, Just print
DataProvider dp = (DataProvider)m_newdatagrid1.getDataProvider();
System.out.println(dp);

check if ur getting some object before you are place it in session.


Regards
Makarand Parab
Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
Hi Makarand

This piece of code is from a tool call Documentum which uses J@EE frame work

ANd yeh Dataprovider dp does return something i have tested it .
String rc1 = dp.getDataField(strAttr1);
System.out.println("the result in jsp page is :" + rc1);


and "SessionState" it is one of Documentum API which is similar to session in JSP.


we can say Dataprovider is like a reusltset ( which is produced when we run a query)

can we pass a resultset in a session variable ?
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
Hi Raj
Do one thing, instead of using SessionSate, put this line
getPageContext().getSession().getAttribute("dap");
and try.
Let me know what you are getting as output.

Yes you can put resultset in session, though it is not a good practice to do so. Anything that is a valid object can be staored in the session.


Regards
MAkarand Parab
payal agrawal
Ranch Hand

Joined: Oct 11, 2005
Posts: 44
You can look at this URL
http://www.java-tips.org/content/view/118/40/
Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
Hi Makarand,

I am extremely sorry for not getting back to you

yes it work :-)


Thanks a lot
 
 
subject: Session Problem