Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

I need an action for all pages for the site

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Considering that i've an header jsp that is imported for each page of the site.. The header is dynamic because i've some details about the logged user, so, it's based on a pre-action for retrieve data (UserActions.java).
If i import the header into a jsp for show the product list, i assume that the preceding action (ProductActions.java) only haves parameters for the products details, while i need those of the user too (contained in the UserActions.java) for show it into the header.
How i can solve this situation without declare the same parameter inside every action class??
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Luca Coraggio wrote:Considering that i've an header jsp that is imported for each page of the site.. The header is dynamic because i've some details about the logged user, so, it's based on a pre-action for retrieve data (UserActions.java).
If i import the header into a jsp for show the product list, i assume that the preceding action (ProductActions.java) only haves parameters for the products details, while i need those of the user too (contained in the UserActions.java) for show it into the header.
How i can solve this situation without declare the same parameter inside every action class??



on userAction save the data on session , and use them later for others page
 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ivan Krasic wrote:

Luca Coraggio wrote:Considering that i've an header jsp that is imported for each page of the site.. The header is dynamic because i've some details about the logged user, so, it's based on a pre-action for retrieve data (UserActions.java).
If i import the header into a jsp for show the product list, i assume that the preceding action (ProductActions.java) only haves parameters for the products details, while i need those of the user too (contained in the UserActions.java) for show it into the header.
How i can solve this situation without declare the same parameter inside every action class??



on userAction save the data on session , and use them later for others page


into the session i only memorize the user id. For retrieve information about him such the username, i need to query the database, and thise event is in the UserActions.java class.

Yes i know that i can memorize username and other useful things into the session, but according to what a friend o mine said, overload the server with this information is a bad thing. Sessions are made for memorize only one information at time, usually the ID.
 
Bartender
Posts: 9615
16
Mac OS X Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Luca Coraggio wrote:. . . according to what a friend o mine said. . .



So your friend would rather you bog down the server with constant database queries? This is a standard engineering tradeoff. You want to display user information. It's up to you to decide the best way to do it. Personally, memory is cheap. Database access is slow. We use the session for whatever user info we display over and over.
 
Marshal
Posts: 67430
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The poor session seems to often be the target of unreasonable loathing and fear. Time to get over it. Sure, you can overuse the session (caching thousands of rows of results for each user would be a good example of a poor use), but storing a modest amount of information is exactly what the session is for and should be used for such.

 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Worrying about session memory is something you should do when you don't have enough of it. A beanful of the most necessary information per user will not fill up your server's memory. If you have that many users that THAT becomes an issue, you will probably have bigger concerns than simply decreasing your session timeout, or in the worst case, having to buy another stick of RAM for your server. Database access for each page header will likely have a bigger impact on your memory usage, and it will definitely impair your performance.

In this case, Joe Ess's suggestion will always be the better choice.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic