| |

VerySource

 Forgot password?
 Register
Search
View: 3012|Reply: 18

Ask a question about session, prawns help!

[Copy link]

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-21 10:30:01
| Show all posts |Read mode
That's it. I participated in a large-scale web project. The front desk was developed using struts. When writing the application, some front desk applications require a lot of business data (public data, which is needed for many front desk displays, about a dozen. Data in each table, each table has about 100 rows), in order to prevent repeated reading of the database, each time the user logs in (when the session is initialized) I put the data into a dozen Arraylist (basically a table (Corresponding to an ArrayList), put the ArrayList into the session through session.setAttribute, so that when the page is used, you can directly read data from the session.
However, when testing later, I found that when displaying data in an ArrayList, there will be garbled characters or other data that should not appear.
For example: Originally ArrayList should save: "Gender, Male, Female"
      The results show: "Student distribution, Dongcheng Branch, ........." This was originally the contents of several other ArrayLists, how did they fit into this ArrayList? Could it be a memory or page problem?

This phenomenon is very random. I can't figure out why. Ask everyone for advice. Thank you very much.

Suspected possible problems:

Possible cause of the problem
(1) Server version issue
(2) Memory overlap may occur: when multiple users initialize a session, they copy the data in the locked code table to their own session. In combination with the Linux memory management mechanism, a page overlap may occur.
(3) In addition, JAVA's data storage mechanism is mostly in a heap manner, which may cause overlap of memory data

Has anyone encountered a similar situation? Tell me!
Reply

Use magic Report

0

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-6-27 15:00:01
| Show all posts
If the amount of data is large, don't put it in the session, it is very memory-intensive
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-1 09:30:01
| Show all posts
I know this is the case, but there is no choice but to do it. Is this the case if there is a lot of data stored in the session?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-4 12:15:01
| Show all posts
Post code to take a look.
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-4 18:15:02
| Show all posts
Oh, it’s a lot of memory to see this for the first time.
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-7-12 13:15:01
| Show all posts
First, what do you use to achieve data persistence
Second, how do you deal with session issues
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-13 13:30:01
| Show all posts
initsession
Initialize session
import javax.servlet.http.HttpSession;

public class InitSession {
   public InitSession() {
   }

   /**
     * Initialize the variables that should be saved in the session, including code and logger.
     * @param session HttpSession
     * @throws Exception
     */
   public static void init(HttpSession session) throws Exception {
       initCode(session);
// initLogger(session);
   }

   /**
     * Initialize code.
     * @param session HttpSession
     * @throws Exception
     */
   private static void initCode(HttpSession session) throws Exception {
       if(session.getAttribute( "_CodeManager ")!=null)return;
// CommonLogger.getInstance().getLogger().info( "Start to initialize code");

       CodeManager codeManager = CodeManager.getInstance();
       codeManager.initCode();
       session.setAttribute( "_CodeManager ", codeManager);
       session.setAttribute( "_auditState ", codeManager.queryAuditState());
       session.setAttribute( "_census ", codeManager.queryCensus());
       session.setAttribute( "_educationalLevel ", codeManager.queryEducationalLevel());
       session.setAttribute( "_education ", codeManager.queryEducation()); //Professional code of the Education Commission
       session.setAttribute( "_studentType ", codeManager.queryStudentType());
       session.setAttribute( "_subschool ", codeManager.querySubschool());
       session.setAttribute( "_station ",codeManager.queryStation());
       session.setAttribute( "_testSubject ", codeManager.queryTestSubject());
       session.setAttribute( "_year ", codeManager.queryYear());
// System.out .println( "dddd "+codeManager.queryYear().size());
       session.setAttribute( "_manageType ",codeManager.queryManageType());
       session.setAttribute( "_stuType ",codeManager.queryStuType());
       session.setAttribute( "_classGrade ",codeManager.queryClassgrade());
       session.setAttribute( "_distributed ",codeManager.queryDistributed());
       session.setAttribute( "_examSort ",codeManager.queryExamSort());//Exam category
       session.setAttribute( "_examSchoolType ",codeManager.queryExamSchoolType());//Exam unit type
       session.setAttribute( "_examItem ",codeManager.queryExamItem());//Exam item
       session.setAttribute( "_employState ",codeManager.QueryEmployState() );//Employment status
       session.setAttribute( "_statusState ",codeManager.queryStatusState() );
       session.setAttribute( "_RewardPunishmentCode ",codeManager.queryRewardPunishmentCode() );
       session.setAttribute( "_RewardLevelCode ",codeManager.queryRewardLevelCode() );
       session.setAttribute( "_UndoSignalCode ",codeManager.queryUndoSignalCode() );
       session.setAttribute( "_RewardPunishmentReason ",codeManager.queryRewardPunishmentReason() );
       session.setAttribute( "_englishDegree ",codeManager.queryEnglishDegree());//English approval code

       session.setAttribute( "_socialCourse ",codeManager.querySocialCourse());//Social course code (degree)

       session.setAttribute( "_punishiment ",codeManager.queryPunishment());//The degree penalty approval code
       session.setAttribute( "_score ",codeManager.queryScore());//Score code
       session.setAttribute( "_teachDep ",codeManager.queryTeachDep());//Teaching department
       session.setAttribute( "_institution ",codeManager.queryInstitution());//Institution
       session.setAttribute( "_firstFocus ",codeManager.queryFirstFocus());//First time again
       session.setAttribute( "_examTypeAlias ​​",codeManager.queryExamTypeAlias());//The evaluation method alias
       session.setAttribute( "_startMark ",codeManager.queryStartMark());//Enable flag (course, teaching point professional)
       session.setAttribute( "_approveMark ",codeManager.queryApproveMark());//Course approval mark
       session.setAttribute( "_cancelMark ",codeManager.queryCancelMark());//Course stop sign
       session.setAttribute( "_mediaType ", codeManager.queryMediaType()); //Media type
       session.setAttribute( "_haveMark ", codeManager.queryHaveMark()); //A code table
       session.setAttribute( "_generalCourse ", codeManager.queryGeneralCourse()); //General course list
       session.setAttribute( "_generalCourse_IdName ", codeManager.queryGeneralCourse_IdName()); //General course list
       session.setAttribute( "_transCode ", codeManager.queryTransCode()); //Transfer code
         session.setAttribute( "_transCodeUp ", codeManager.queryTransCodeUp()); //Upload transmission code
           session.setAttribute( "_transCodeReceive ", codeManager.queryTransCodeReceive()); //Receive transmission code
       session.setAttribute( "_openSpeciality ", codeManager.queryOpenSpeciality()); //Open professional
       session.setAttribute( "_credentialType ", codeManager.queryCredentialType()); //Certificate type
       session.setAttribute( "_socialSubjcetSort ",codeManager.querySocialSubjcetSort());//Social subject category
       session.setAttribute( "_examStateCode ",codeManager.queryExamStateCode());//The audit status code table
       session.setAttribute( "_netExamCourse ",codeManager.queryNetExamCourse());//Net test subjects
       CommonLogger.getInstance().getLogger().debug( "Initialized code completion");
   }
}
Reply

Use magic Report

1

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-7-16 12:45:02
| Show all posts
On the contrary, it was a garbled problem for a long time. I thought it was all changed to UTF-8 format.
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-17 08:15:01
| Show all posts
Brother, see it clearly, it is not a garbled problem, the corresponding item extracted from the corresponding session.setAttribute is not garbled, but incorrect data, for example: originally the session.getAttribute ("sex") should get "male" "female" , But now the content of other items is obtained, for example: "Beijing" "Shijiazhuang" "Jinan"............ Moreover, this phenomenon is not reproducible. He will appear on any machine anytime, anywhere, on different machines, so he can't figure out what is going on. Now it is mainly suspected that it is a memory problem, and the session is suspected. Overlap. I don't know if anyone has encountered this situation.
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-17 12:00:01
| Show all posts
Try not to write this, if you don’t cross the page, you can directly encapsulate it again in VECTOR, and then submit it to the next page, or claim a temporary file and read it again, or claim a temporary table in the database. If you do this, you will definitely have problems, and Irregular problems, you can find the root cause of Microsoft, after all, do not understand the core wit of SESSION
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list