In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to share the value of Session in JSP and Asp.net, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail, people with this need can come to learn, I hope you can get something.
Session in Web refers to the time it takes for a user to browse a website from the time he enters the site to the time the browser is closed, that is, the time it takes the user to browse the site. So we can see from the above definition that Session is actually a specific concept of time.
What happens when the value of Session is between JSP and Asp.net?
At the beginning of this topic, the idea is to serialize Session in Asp.net and save it to the database as binary data, then JSP reads the binary data in the database and deserializes it into Session object, and then forcibly converts it into Java Session object. During the conversion on the Java side, there is an error, and the information on the Internet has not been solved, so a replacement method is adopted.
The idea of an alternative way:
In the login ASPX file, save the variable values in Session to a table in the database after the login is successful. The keyword uses the SessionID of the Session object of Asp.net, and then create an ASPX file and get the
Get the SessionID of the currently logged-in user, and use the Asp.net redirect statement to go to the JSP file. The path format of the URL request is test.jsp?aspnetsessionid=ffj12d455p0ujr45vdqwhh55, if
Asp.net did not log in or login was unsuccessful. Although there is a value of SessionID, there is no data associated with the SessionID in the database.
Some readers may find that the path of a request can be done without a request like test.jsp?aspnetsessionid=ffj12d455p0ujr45vdqwhh55. Yes, a party like test.jsp?userid=1111 can be used.
Of course, userid is the value obtained by Asp.net after login, but some users can know the sensitive data of USERID (user number).
Create a table
◆ table name:
◆ iis_session
◆ field name:
◆ id varchar (26)-- SessionID for storing Asp.net
◆ userid int (4)-- stores the user ID after a successful login
◆ power int (4)-- stores the user's permission number
The value of Session is found in the source code snippet of the Asp.net program:
/ * after the login is successful, put the following CODEING in the login verification ASPX page * / / record the Session value to the database private void WriteSession2DB (string sessionID,string sUID,string sPWR) {/ / connect the database code, and the reader adds string sessID = sessionID; string strSQL = "insert into iis_session (id,userid,power) values (@ seionID,@UID,@PWR)" / / webmod.sqlConn is the connection object of the database. Readers replace it with their own 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, and readers add their own} / * when the user exits the system, a row of data corresponding to SessionID in the database is deleted, which can be placed on the exit page, or during the Session_END process of Global.asax * / / delete the Session value private void RemoveSession4DB () {/ / connection database code in the database, and the reader adds string sessID = Session.SessionID. String strSQL = "delete from iis_session where id='" + sessID+ "'"; / / webmod.sqlConn is the connection object of the database, and readers replace it with their own database connection SqlCommand sqlCmd = new SqlCommand (strSQL,webmod.sqlConn); sqlCmd.ExecuteNonQuery () / / close the database connection, and readers add an ASPX page redirected to JSP. 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);} to the PAGE_LOAD of this ASPX page.
The value of Session is found in the source code snippet of the JSP program:
At this point, the sharing of the value of Session between JSP and Asp.net comes to an end. Although it is not a very good method, it can also be used to protect some sensitive data of users.
I will continue to consider using serialization and deserialization to share Session objects between different Web languages instead of sharing Session values above.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.