You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by andy wix <st...@hotmail.com> on 2005/05/23 13:18:04 UTC
Stateless web apps
Hi,
I am working at a place that doesn't use session state for their web apps.
The reason given is that they have 2 physical servers and 2 Oracle
Application Servers running on each of these machines for failover. From
the little I know about clustering, I thought that if everything in the
session implements Serializable then session state is tranparently valid
accross requests - even if you end up on another jvm.
Has anyone else ever heard of this restriction - I can see problems e.g.,
can't use Struts tokens to defeat the usual refresh problems.
More immediately, I have a problem with a typical scenario. My normal
approach is:
I have a 'preload' action that gets an ArrayList of data from the db and
sets this in the session.
Then forward to the jsp that displays this stuff.
This page has something like:
<c:forEach var="wrap" items="${Assignments}" varStatus="status">
<TR>
<TD><c:out value="${status.index+1}"/></TD>
<TD>
<c:url var="viewApp" value="/viewNode.do">
<c:param name="indexPos" value="${status.index}" />
</c:url>
<html:link href="${viewApp}">
<c:out value="${wrap.applicationVO.applicationName}"/>
</html:link>
</TD>
This gives me an index of the link that was clicked and in the next action I
simply look this value up from the ArrayList in the session.
Does anyone know how this functionality could be achieved without using the
session?
Thanks,
Andy
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger 7.0 today!
http://messenger.msn.co.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Stateless web apps
Posted by Laurie Harper <la...@holoweb.net>.
andy wix wrote:
> I am working at a place that doesn't use session state for their web apps.
> The reason given is that they have 2 physical servers and 2 Oracle
> Application Servers running on each of these machines for failover.
> From the little I know about clustering, I thought that if everything
> in the session implements Serializable then session state is
> tranparently valid accross requests - even if you end up on another jvm.
>
> Has anyone else ever heard of this restriction - I can see problems
> e.g., can't use Struts tokens to defeat the usual refresh problems.
Sharing sessions between containers ('session clustering') is not a
standard feature -- i.e. the Servlet spec neither requires this
capability nor specifies how it should be impelemnted. However, most
modern contains do support session clustering, in their own proprietary
way. For example, Tomcat supports session clustering via shared disk,
JDBC datastore, etc.
I don't know what session clustering abilities Oracle Application Server
has but it can probably be configured to do this. Bear in mind that
there are performance tradeoffs to consider as well as opperational
impact -- for example, if you cluster sessions via shared disk, you now
need to make your shared disk array redundant as well.
If you can implement your application without relying on sessions at
all, your life will be simpler ;-) If you do need to implement session
clustering, consider using host affinity as an alternative. With host
affinity, the load balancer is configured to share sessions between the
servers equally, but allways route requests for a particular session to
the same server. That saves you the overhead of session clustering, at
the cost that if one of the application servers goes down all users
whose sessions were housed there will loose their session and have to
log in again on the other server.
L.
>
> More immediately, I have a problem with a typical scenario. My normal
> approach is:
> I have a 'preload' action that gets an ArrayList of data from the db and
> sets this in the session.
> Then forward to the jsp that displays this stuff.
> This page has something like:
>
> <c:forEach var="wrap" items="${Assignments}" varStatus="status">
> <TR>
> <TD><c:out value="${status.index+1}"/></TD>
> <TD>
> <c:url var="viewApp" value="/viewNode.do">
> <c:param name="indexPos" value="${status.index}" />
> </c:url>
> <html:link href="${viewApp}">
> <c:out value="${wrap.applicationVO.applicationName}"/>
> </html:link>
> </TD>
>
> This gives me an index of the link that was clicked and in the next
> action I simply look this value up from the ArrayList in the session.
>
> Does anyone know how this functionality could be achieved without using
> the session?
Assuming you can rebuild the list at any time, you can use request scope
instead of session scope and rebuild the list at the start of each action.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org