Monday, October 18, 2010

Session of the value of the share in the JSP and Asp.net



Specific to the Web in the Session refers to a user browsing a website, from the access site to close the browser after a period of time, that is, users browse the site by the time it takes. From the above definition, therefore, we can see, Session is actually a particular concept of time.

The value of Session between Asp.net in JSP and what is the situation?

The beginning of this topic in the sequence of ideas is Asp.net Session in order to save the binary data to the database, and then reads the database from the JSP deserialize binary data into Session object, and then be converted into Java's Session object, in the JAVA side conversion When an error, searched online data also failed to resolve, it uses an alternative approach.

Replace the idea of the way:

Login ASPX file, the login will succeed Session of the variable values saved to the database in a table, keyword use the Session object Asp.net SessionID, and then create a ASPX file, check

Get the current logged-on user's SessionID, and use the Asp.net redirection statement, go to the JSP file, the URL path requested format test.jsp? Aspnetsessionid = ffj12d455p0ujr45vdqwhh45, if

Asp.net not logged in or login is not successful, although there SessionID value, but the database is no data associated with the SessionID

Some readers may find that not test.jsp? Aspnetsessionid = ffj12d455p0ujr45vdqwhh45 the path of such requests can be completed, yes, you can use test.jsp? Userid = 1111 so the parties

Also pass a value type, of course, Asp.net login userid is successful, the value obtained, but that some users can know the USERID (user ID) of this sensitive data.

The establishment of a table

鈼?table name:

鈼?iis_session

鈼?field name:

鈼?id varchar (26) - store the SessionID Asp.net

鈼?userid int (4) - store the user ID after a successful login

鈼?power int (4) - store the user's permission number

Session of the value in Asp.net program source code fragment:

/ * After successful login, you can verify the following CODEING on the login ASPX page * / / / Record Session value to the database private void WriteSession2DB (string sessionID, string sUID, string sPWR) (/ / connect to the database code, readers add their own string sessID = sessionID; string strSQL = "insert into iis_session (id, userid, power) values (@ seionID, @ UID, @ PWR)"; / / webmod.sqlConn is the database connection object, and the reader into their own replacement The database connection SqlCommand sqlCmd = new SqlCommand (strSQL, webmod.sqlConn); sqlCmd.Parameters.Add ("@ seionID", SqlDbType.VarChar). Value = sessID; sqlCmd.Parameters.Add ("@ UID", SqlDbType . Int). Value = Convert.ToInt32 (sUID.Trim ()); sqlCmd.Parameters.Add ("@ PWR", SqlDbType.Int). Value = Convert.ToInt32 (sPWR.Trim ()); sqlCmd.ExecuteNonQuery (); / / close the database connection, the reader Add) / * When the user exits the system, the corresponding database row data SessionID to delete, may be placed out of the page, or the Global.asax of Session_END process * / / / Remove Database Session value private void RemoveSession4DB () (/ / connect to the database code, the reader Add string sessID = Session.SessionID; string strSQL = "delete from iis_session where id = '" + sessID +"'"; / / webmod.sqlConn is the database connection object, readers replace their own database connection SqlCommand sqlCmd = new SqlCommand (strSQL, webmod.sqlConn); sqlCmd.ExecuteNonQuery (); / / close the database connection, the reader Add) / * a redirect to the JSP the ASPX page, in the ASPX page PAGE_LOAD Add the following code * / private void Page_Load (object sender, System.EventArgs e) (string strSessionID = Session.SessionID.Trim (); String strRoot = " http://localhost/test.jsp?aspnetsessionid = "+ strSessionID; Response.Redirect (strRoot, true);)

Session of the value in the JSP source code fragment:

Asp.net Session Value UserID = "+ sUID +" H1>

"); Out.print ("
Asp.net Session Value Power = "+ sPower +" H1>

");) Rs.close (); db.dbConnClose ();%>

To this Session of the value of the share in the JSP and Asp.net end on the first, although not a very good method, but can also be used, also to protect the user's sensitive data.

I will continue to consider the use of serialization and deserialization of the way to achieve shared between different Web languages Session object rather than the above, the value of sharing Session







相关链接:



Kelon Did Not Deny That Gu Chujun Was Under Surveillance



Infomation SEASONAL - Screen Savers



UML in practice, the current situation and some of The recommendations [2]



STORM Two Strokes Buttoned Brightness Adjustment



land phones questions and answers



Beijing-Shenyang Expressway: Breaking the "separatism," the first



Write a bean class CRITERIA (2)



51.com Tencent moved the cake



Recommend E-Mail Tools



Assembly LANGUAGE instruction and by Example



PERA2009: "Made in China" the "engine"



DivX to VOB



TS To WMV



HR HR in the eyes of men and WOMEN



FLV to 3GP



No comments:

Post a Comment