• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

where to write session related code

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have action ,helper and business logic classes in my project . Now I m in the phase of integrating the unit functionalities , my concern is which file to choose to write the code for maintaing the session of the user .

where can i get roles and responsibilites of action , helper and business logic files are they part of design patterns or something else.
what do i read for such issues.

Thanks in advance .
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you mean by session?
 
jaiser roney
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from the term session i mean session of the user ie the time between login and logout in the application
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. Anyway you're developing a web application or desktop application. What are frameworks you are using?

And can you rephrase your question? I don't understand what the problem is.
 
jaiser roney
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m developing a web application in struts 2.0 framework . My question is where to write the code for maintaing the session of the user.

The session maintained by following code
org.apache.struts2.ServletActionContext.getRequest().getSession()
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should write session management code in Struts 2 Actions.
 
jaiser roney
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there any reason why should i write the code in Action class ?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jaiser roney wrote:is there any reason why should i write the code in Action class ?


Every Java web application framework built on top Servlet, the framework provides a Front Controller Servlet which intercepts all incoming requests and delegates to Page Controllers/Actions, and then the Controller/Action forward to View. It's just natural to write HttpSession related code in Action classes.

You should try to write some code to get better understanding.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Every Java web application framework built on top Servlet, the framework provides a Front Controller Servlet which intercepts all incoming requests and delegates to Page Controllers/Actions, and then the Controller/Action forward to View.



This is where the biggest misunderstandings and mistakes typically occur. None of the popular MVC-based web frameworks address a Model or provide a container for writing Model business logic. Action objects or Page Controller objects are still part of the Controller. They are the extensible elements of the Controller that are customized and developed for a specific application. They work with a "servlet" object that usually comes with the framework. In a Struts-based component, all of the objects that are created from the struts-config.xml file are Controller objects, for example.

The correct execution path is View -- Controller -- Model -- Controller -- View. How does the Controller know how to communicate with the Model? You write custom Controller Action classes.

In terms of "session" related information, if it is HttpSession related data, then it could fit in well in a Http-based Controller, e.g Action classes/objects. However, if it is another type of "business-oriented" session data, then it would be coded in Model (or Business tier).
 
Your mother was a hamster and your father was a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic