aspose file tools*
The moose likes Struts and the fly likes Session tracking and tiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session tracking and tiles" Watch "Session tracking and tiles" New topic
Author

Session tracking and tiles

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Hi. I've just finished "Struts 2 in Action" book, and I didn't find at any place wird about session tracking. Considering that Struts architecture is built upon Servlet API ( and on servlet we know that sesion tracking is preserved by cookies or url writing), I guess that framework by itself maintain such a tracking, isn't it?
And also I'm interesting where I place the tiles declaration file (tiles.xml) in the application (in the WEB-INF/classes, or ? ) ?
Thanks...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The reason you didn't find any information about session tracking in a Struts book is that session tracking is not done by Struts or any other web framwork. It's done by the application server (Tomcat, WebLogic, WebSphere, etc.). To understand how your application server does it, consult the relevant documentation.


Merrill
Consultant, Sima Solutions
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Well, Servlets, also deployed on (let say) Tomcat, use mentioned mechanisms (cookies and URL rewriting) and it's specified by Servlet specification, right? I mean, it's not defined by server but Servlet spec.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Servers implement the Servlet spec. The server implements session tracking as defined by the spec.

Do you have a specific question about Struts and sessions?

The tiles definition files can go wherever you want as long as you define the location. I'd consider reading the Tiles documentation regarding configuration. Note also that Tiles 2 is no longer part of the Struts project.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Aha, Tiled are plugins, it's ok. Well about session tracking, just as I've asked, do I need to perform certain explicit method of session tracking (such as URL rewriting just as I did in pure Servlet based web application), do I need such a thing to perform in Action class (just as I did , or what?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

According to the "using tags" docs, the <s:url...> tag will:

URL-encode the link with the Java session ID, if needed, so that the Java session can be retained across requests.

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Well, I guess It will :-) But can I do that from Action like in Servlets where also in the sort of authentication servlet I should retrieve a session from request to start session tracking, or only in Struts, it could e done through the tag, if it is quite enough?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You *could* do it in an action, but I don't really know why you'd want to. Unless you specifically disable sessions (including on every JSP page) you're going to have a session, as far as I know.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Aha, no really matter just curiosity, because I don't want to leave any "whole" in order to built "firm" knowledge... Thanks a lot...
 
 
subject: Session tracking and tiles