Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in session  RSS feed

 
belin raj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using <h:command button>, when I click this button if session is not null I displayed page2 if session is NULL I displayed the timeoutpage, but when the session is null for first click same page is displayed(not timeout page)but for the second click it works fine

Can anyone help me regarding this

Hi

This is my Config xml
<managed-bean>

<managed-bean-name>authenticationValue</managed-bean-name>

<managed-bean-class>coreservlet.AuthenticationValue</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>
<navigation-rule>

<from-view-id>/home.jsp</from-view-id>

<navigation-case>

<from-outcome>logout</from-outcome>

<to-view-id>/LogoutIndex.jsp</to-view-id>

</navigation-case>

<navigation-case>

<from-outcome>statement</from-outcome>

<to-view-id>/statement.jsp</to-view-id>

</navigation-case>

<navigation-case>

<from-outcome>timeout</from-outcome>

<to-view-id>/HomeSession.jsp</to-view-id>

</navigation-case>

</navigation-rule>



This is my AuthenticationValue



public class AuthenticationValue

{



String userid;

String xmlvalue;

ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();

HttpServletRequest request =(HttpServletRequest)context.getRequest();

HttpServletResponse response=(HttpServletResponse)context.getResponse();

HttpSession session = request.getSession(true);



String str=session.getId();





public String Validation() throws IOException

{





String name = request.getParameter("saif1:name");

String password = request.getParameter("saif1 assword");



System.out.println(" Name "+name);

System.out.println(" password "+password);

//EncryptPwd enp =new EncryptPwd();

//password=enp.EncPwd(password);

//System.out.println("Encptpasswd is"+password);

Authentication auth = new Authentication(name,password);

System.out.println("session id is"+str);

session.setAttribute("sesid",name);



boolean success = auth.login();

userid = (String) session.getAttribute("sesid");



System.out.println("this is the userid creation"+userid);



if (success)

{

xmlvalue=auth.getXMLData();

//System.out.println("this is xml value"+ xmlvalue);

session.setAttribute("xmlval",xmlvalue);

return("success");



}

else

{

return("bad-password");

}



}



public String displayHome() throws IOException

{

System.out.println("this is display home");



if (userid == null)

{

System.out.println("this is the userid home"+userid);

return("timeout");

}



else

{

System.out.println("this is the userid home else"+userid);

return("home");

}



}
}

Probelm
~~~~~~~

When The session is valid there is no problem But if it is invalid (null) then, when I click the first time it refreshed the same page but I am writing the code to display the someother page.But in the second time its works fine

can you help me where I have to change

thanx
inico
inicobelin@rediffmail.com
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!