1. Read a document "Session Detailed" in the BEA dev2dev, combined with experience in the EPAYMENT project, summarized as follows:
1). Set the session: (Getimg.java)
/ / Get a random number of 1000-9999
String s = "";
Int IntCount = 0;
INTCOUNT = (New Random ()). Nextint (9999); //
IF (IntCount <1000) INTCOUNT = 1000;
S = int 4T "";
/ / Assignment to the session
HttpSession mysession = request.getsession (TRUE);
IF (MySession! = NULL)
{
Mysession.setttribute ("Getimgagain", S);
Else
{
System.out.println ("GetImgagain> The session got is null!");
}
2.) Get session (Deduced.jsp)
String sessionValue = (string) session.getattribute ("getImg");
String Validatecode = Request.GetParameter ("Validatecode");
IF (sessionValue! = null)
{
IF (sessionValue.equals (validatecode))
{
System.out.println ("Deducted.jsp> Validatecode IS OK!");
}
Else
{
Response.sendRedirect ("Error.jsp? msgid = 6");
Return;
}
Else
{
Response.sendRedirect ("Error.jsp? msgid = 6");
Return;
}