Porletsession and session variables in portlet

I don't know why the values (BegDate, EndDate) are still null after I click an URL link althought I did set up session varaibles. Here is the major portion of my Code. Hope you can help me find out the problem.

in view.jsp ( this is first page)

<div class="portlet-generic-container" style="padding-top:5px;padding-bottom:5px;">

<label>Date Range: <input type="text" size="20" maxlength="30" name= "BegDate" value="<%=in_format.format(cal.getTime())%>" > - <input type="text" size="20" maxlength="30" name="EndDate" value=<%=s%> > ( enter as mm/dd/yyyy)</label>

</div

In view2.jsp ( this is page from view.jsp submit button ) I can have the BegDate and EndDate values passed successfully from view.jsp user input.

><%

HttpSession session = request.getSession ();

//String MyBegDate = session.getAttribute ( "BegDate" ) ;

//String MyEndDate = session.getAttribute ( "EndDate" ) ;

session.setAttribute ( "BegDate", MyBegDate ) ;

session.setAttribute ( "EndDate", MyEndDate ) ;

%>

<div class="portlet-generic-container" style="padding-top:5px;padding-bottom:5px;">

<label>Start Date: <input type="text" size="20" maxlength="30" name= "BegDate" value="<%=MyBegDate%>"/> -

<label>End Date: <input type="text" size="20" maxlength="30" name="EndDate" value="<%=MyEndDate%>"/></label>

The output is a list of IP address with an URL link under each. The IP link will trigger to another page called "IPByHourPage.jsp.

In IPByHourPage.jsp When cicking onto IpHourPage, the BegDate and EndDate all dispalyed null values. It seems the session doesn't work

<%

HttpSession session = request.getSession ();

String MyBegDate = request.getParameter("BegDate");

String MyEndDate = request.getParameter("EndDate");

session.setAttribute ( "BegDate", MyBegDate ) ;

session.setAttribute ( "EndDate", MyEndDate ) ;

System.out.println("BegDate from hourly " + MyBegDate);

System.out.println("Endate from hourly " + MyEndDate);

%>

<label>Start Date: <input type="text" size="20" maxlength="30" value="<%=MyBegDate%>"/> -

<label>End Date: <input type="text" size="20" maxlength="30" value="<%=MyEndDate%>"/></label>

In NFD.java here is the doview method

protected void doView(RenderRequest request, RenderResponse response)

throws PortletException, IOException, UnavailableException {

response.setContentType("text/html");

PortletSession session = request.getPortletSession();

String MyBegDate = request.getParameter( "BegDate" ) ;

String MyEndDate = request.getParameter ( "EndDate" ) ;

String MyNetworks = request.getParameter("networks");

PortletURL renderURL = response.createRenderURL();

renderURL.setPortletMode(PortletMode.VIEW);

request.setAttribute("renderURL", renderURL.toString() );

String GotoRenderAction = request.getParameter("goto");

String MyIPHourAction = request.getParameter("Ret_IPHourPage");

if ( (MyIPHourAction!=null) && MyIPHourAction.equals("Ret_IPByHourPage") )

{

session.setAttribute("BegDate", MyBegDate);

session.setAttribute("EndDate", MyEndDate);

PortletRequestDispatcher kk = getPortletContext().getRequestDispatcher("/view2.jsp");

kk.include(request, response);

}

if (MyIPHourAction != null && MyIPHourAction.equals("Ret_IPByHourPage"))

{

session.setAttribute("BegDate", MyBegDate);

session.setAttribute("EndDate", MyEndDate);

PortletRequestDispatcher mm = getPortletContext().getRequestDispatcher("/view2.jsp");

mm.include(request, response);

}

if (GotoRenderAction != null && GotoRenderAction.equals("IpByHourPage"))

{

session.setAttribute("BegDate", MyBegDate);

session.setAttribute("EndDate", MyEndDate);

System.out.println("BegDate" + MyBegDate);

System.out.println("Endate" + MyEndDate);

PortletRequestDispatcher mm = getPortletContext().getRequestDispatcher("/IpByHourPage.jsp");

mm.include(request, response);

}

if(MyEndDate!= null )

{

session.setAttribute("BegDate", MyBegDate);

session.setAttribute("EndDate", MyEndDate);

PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/view2.jsp");

prd.include(request, response);

}

else if (MyEndDate==null && GotoRenderAction == null)

{

PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/view.jsp");

prd.include(request, response);

}

else if (MyEndDate==null )

{

PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/view.jsp");

prd.include(request, response);

}

}

Please help me why my session doesn't work?

[5047 byte] By [wasabi3689a] at [2007-11-26 20:57:48]
# 1
Try setting the portletsession with Application Scope as given below.session.setAttribute("BegDate",MyBegDate,PortletSession.APPLICATION_SCOPE);
UmaChithraa at 2007-7-10 2:27:18 > top of Java-index,Web & Directory Servers,Portal Servers...
# 2

It doesnt work either. Here is my code updated

protected void doView(RenderRequest request, RenderResponse response)

throws PortletException, IOException, UnavailableException {

response.setContentType("text/html");

PortletSession session = request.getPortletSession();

String MyBegDate = request.getParameter( "BegDate" ) ;

String MyEndDate = request.getParameter ( "EndDate" ) ;

String MyNetworks = request.getParameter("networks");

PortletURL renderURL = response.createRenderURL();

renderURL.setPortletMode(PortletMode.VIEW);

request.setAttribute("renderURL", renderURL.toString() );

String GotoRenderAction = request.getParameter("goto");

String MyIPHourAction = request.getParameter("Ret_IPHourPage");

System.out.println("Hello this is Beg in doview " + MyBegDate);

System.out.println("Hello this is End in doview " + MyEndDate);

System.out.println("Hello this is session in doview before all if " + session);

// PortletSession sin= request.getPortletSession(false));

if ( ( (MyIPHourAction!=null) && MyIPHourAction.equals("Ret_IPByHourPage") ) || (MyIPHourAction != null && MyIPHourAction.equals("Ret_IPByHourPage"))|| (MyEndDate!= null ))

{

System.out.println("this is inside if for view2 " + MyIPHourAction);

PortletSession sin = request.getPortletSession(true);

sin.setAttribute("BegDate", MyBegDate, PortletSession.APPLICATION_SCOPE);

sin.setAttribute("EndDate", MyEndDate, PortletSession.APPLICATION_SCOPE);

System.out.println("BegDate is for view2 " + MyBegDate);

System.out.println("Endate is for view2 " + MyEndDate);

System.out.println("sin is for view2 " + sin);

PortletRequestDispatcher kk = sin.getPortletContext().getRequestDispatcher("/view2.jsp");

kk.include(request, response);

}

if ( ( GotoRenderAction != null && GotoRenderAction.equals("IpByHourPage") ) )

{

System.out.println("inside if for IPByHourpage" + GotoRenderAction);

PortletSession sin = request.getPortletSession(true);

sin.setAttribute("BegDate", MyBegDate, PortletSession.APPLICATION_SCOPE);

sin.setAttribute("EndDate", MyEndDate, PortletSession.APPLICATION_SCOPE);

System.out.println("BegDate for IPPage " + MyBegDate);

System.out.println("Endate for IPPage " + MyEndDate);

System.out.println("sin value in IPByHourPage " + sin);

PortletRequestDispatcher mm = sin.getPortletContext().getRequestDispatcher("/IpByHourPage.jsp");

mm.include(request, response);

}

else if ( (MyEndDate==null && GotoRenderAction == null ) || (MyEndDate==null ) )

{

PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/view.jsp");

prd.include(request, response);

//System.out.println("view");

}

}

I put the system print statment for debug. It is clear to me that "session" has the same session value with "sin" when each time I either submit or click a link in a page. If BegDate and EndDate are null in "session", BegDate and EndDate are slo null in "sin". If BegDate and EndDate are date in "session", BegDate and EndDate are also date in "sin". In IpByHOurPage If BegDate and EndDate are null after I click an IP address link in view2.jsp. I suspect if I should put parameters as below in view2.jsp like

<portlet:renderURL var="aURL" >

<portlet:param name="goto" value="IpByHourPage"/>

<portlet:param name="BegDate" value="<%=MyBegDate%>"/>

<portlet:param name="EndDate" value=<%=MyEndDate%>/>

</portlet:renderURL>

<a href= "<%=aURL.toString() %>" ><%=MyIP%></a>

Can you help me see if anything wrong with the doView? Why still null

wasabi3689a at 2007-7-10 2:27:18 > top of Java-index,Web & Directory Servers,Portal Servers...
# 3

After I added above piece code, I got the following

Caused by: javax.servlet.ServletException: Unparseable date: "3/8/2007 null"

at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl .java:858)

at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.j ava:791)

at org.apache.jsp.view2_jsp._jspService(view2_jsp.java:706)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

wasabi3689a at 2007-7-10 2:27:18 > top of Java-index,Web & Directory Servers,Portal Servers...