Web backend does not get the value in session (loading sessions from persistent storage), then use JS to pass the value

Source: Internet
Author: User
Tags addchild session id

The program on the line seems to not get the domain data from the session, restarting the Tomcat view log log found that there is an error. The error message is as follows

22-sep-2016 00:52:16.562 SEVERE [localhost-startstop-1] org.apache.catalina.session.StandardManager.startInternal Exception loading sessions from persistent Storagejava.io.StreamCorruptedException:invalid Type code:00At java.io.ObjectInputStream.readObject0 (Objectinputstream.java:1381) at Java.io.ObjectInputStream.defaultReadFields (Objectinputstream.java:2018) at Java.io.ObjectInputStream.defaultReadObject (Objectinputstream.java:503) at Java.lang.Throwable.readObject (Throwable.java:914) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Nativemethodaccessorimpl.java:62) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (Method.java:498) at Java.io.ObjectStreamClass.invokeReadObject (Objectstreamclass.java:1058) at Java.io.ObjectInputStream.readSerialData (Objectinputstream.java:1909) at Java.io.ObjectInputStream.readOrdinaryObject (Objectinputstream.java:1808) at Java.io.ObjectInputStream.readObject0 (Objectinputstream.java:1353) at Java.io.ObjectInputStream.readObject (Objectinputstream.java:373) at Org.apache.catalina.session.StandardSession.doReadObject (Standardsession.java:1602) at Org.apache.catalina.session.StandardSession.readObjectData (Standardsession.java:1090) at Org.apache.catalina.session.StandardManager.doLoad (Standardmanager.java:218) at Org.apache.catalina.session.StandardManager.load (Standardmanager.java:162) at Org.apache.catalina.session.StandardManager.startInternal (Standardmanager.java:356) at Org.apache.catalina.util.LifecycleBase.start (Lifecyclebase.java:147) at Org.apache.catalina.core.StandardContext.startInternal (Standardcontext.java:5320) at Org.apache.catalina.util.LifecycleBase.start (Lifecyclebase.java:147) at Org.apache.catalina.core.ContainerBase.addChildInternal (Containerbase.java:725) at Org.apache.catalina.core.ContainerBase.addChild (Containerbase.java:701) at Org.apache.catalina.core.StandardHost.addChild (Standardhost.java:717) at Org.apache.catalina.startup.HostConfig.deployWAR (Hostconfig.java:940) at Org.apache.catalina.startup.hostconfig$deploywar.run (Hostconfig.java:1816) at Java.util.concurrent.executors$runnableadapter.call (Executors.java:511) at Java.util.concurrent.FutureTask.run (Futuretask.java:266) at Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1142) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:617) at Java.lang.Thread.run (Thread.java:745)

The following information found on the Internet:

tomcat/work/catalina/localhost/Project name/sessions.ser session does not time out when the server is turned off large time is serialized to the project name/sessions.ser startup time to load again, when loading error , remove the file and restart it.

With this problem, it is known that requet.getsession () gets the Standardsession object, and Standardmanager manages the session collection when the Servlet container is closed, Standardmanager calls the Unload method to write the Standardsession object in the session set to the "Sessions.ser" file, because the servlet container process is killed directly, without unload persistence, So the error when resuming the session. So be careful to call the start and stop commands of the servlet container later.

Although I did this, restarting Tomcat did not error, but I still get no value in my session.

So modify the program, I print out the server in the background of the session ID discovery page Every drop-down request to the session ID is different (but in the local test session ID is the same, I use the form of $.get (URL) access to the server, Does each visit create a new session? Not tested for the time being).

As the project needs to be online as soon as possible, in the foreground JS wrote a method the user obtains the parameters in the address bar, the method is as follows

url:http://www.baidu.com/domain/?domain=taobao.com
functiongetquerystring (name) {varReg =NewRegExp ("(^|&)" + name + "= ([^&]*) (&|$)"); varr = Window.location.search.substr (1). Match (REG); if(r!=NULL)returnUnescape (r[2]);return NULL;} varDomain = ""; varMyurl=getquerystring ("Domain"); if(Myurl! =NULL&& myurl.tostring (). length>1) {domain= getquerystring ("Domain"); }
Here you can get to taobao.com

Web backend does not get the value in session (loading sessions from persistent storage), then use JS to pass the value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.