This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble with application scoped list  RSS feed

 
John Reacher
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have a strange issue in a JSP. I'm sure it's something simple that I'm missing. Basically I have a page where an administrator can login and do certain things, which works fine. That is a JSP and the actions on it are done by a Servlet. I also have another JSP which displays a user page (user Logs in from same page as the Administrator. Any info sent from that user page is also validated by the same Servlet.

In the user page, they have the option to change their information (ex. Name, phone) which is stored in an arrayList.

This arraylist is application level, and I have a seperate Java class that takes it in and performs additions and deletions from it.

I'm using the usebean property and am setting the arrayList attribute from the application as that beans attribute. Ex. Value="${applicationScope.arrayname}".

This all works fine. But in the user page, the first time they edit something and the JSP sends to itself and registers that they entered text, it does indeed send the new info and edit the arrayList. However, if you try a second time, it gives me an argument mismatch error. The arguments going into the Java class method to edit the arrayList are the same, so this puzzles me.

Also, if I run the app again and Try to login as the Administrator, it gives me an error that a string cannot be cast to an ArrayList. I'm never even performing such a cast.

Does anyone have any ideas?

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Reacher wrote:This arraylist is application level ...

Well, first things first. That's a boatload of trouble right there.

You are taking user-specific data and storing it in application level? Why? if multiple people are using your app, they will all access this same variable. User-specific information that persists across requests is best kept in the session, which exists on a per-user basis.
 
John Reacher
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using application level because I want the Administrator to have the same ArrayList too. That way he can see any changes made to a user's string in the ArrayList.

At the top of each page I'm doing a usebean and calling it myList1 on the two JSPs (Administrator JSP and Client JSP) so that both pages have access to an instance of the Java class that manipulates it's attribute (the application ArrayList). Could this be causing the problem?
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When your code is throwing an exception, it's almost always a good idea to look at that code. Guessing based on a general description of the application is rarely helpful.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Reacher wrote:I'm using application level because I want the Administrator to have the same ArrayList too. That way he can see any changes made to a user's string in the ArrayList.

So you only expect one user to ever be using the system?

 
John Reacher
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No there is the Administrator who uses it and sees one page, and then the users who see a different user page (both JSPs) when each Logs in, respectively. I just find it weird that when a user changes his details once, it works and the ArrayList is updated, but then if he does it again it says argument mismatch exception. It should never do that because there is only one method with that name and it always passes in the correct arguments.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So there will be one admin, and one user. Only one. Ever?

In any case, you'll need to give us more details about the error. What is the exact wording, and where in the code does it occur?

Be sure to UseCodeTags when posting code and error messages to preserve formatting.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!