You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Geert Bevin <gb...@uwyn.com> on 2003/05/23 19:51:03 UTC

Disable sessions

Hello,

I've been struggling with the 1.1-rc1 release since I didn't seem to be 
able to disable sessions in Struts. I've read through the mailinglist 
and tried several solutions. I also noted the responses that shortly 
say 'Struts doesn't handle sessions, your servlet container does'. Well 
I have the impression that Struts does manage them.
I've briefly read through the sources and there are several locations 
where Struts clearly starts a new session. I haven't investigated in 
detail though. Maybe someone else can enlighten me?
For that purpose I've tried the shortest possible testcase and even 
removed a JSP view. Still, Struts tries to start a session.
Below are all the related files. Does anyone have an idea what I can do 
to completely disable sessions?

Thanks for the help,

Geert Bevin

/** begin WEB-INF/web.xml **/
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
	<servlet-name>action</servlet-name>
	<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
	<servlet-name>action</servlet-name>
	<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
/** end WEB-INF/web.xml **/

/** begin WEB-INF/struts-config.xml **/
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 
1.0//EN"
           "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>
<action-mappings>
     <action path="/hello" type="HelloWorldAction" scope="request">
     </action>
</action-mappings>
</struts-config>
/** end WEB-INF/struts-config.xml **/

/** begin WEB-INF/classes/HelloWorldAction.java **/
import org.apache.struts.action.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;

public class HelloWorldAction extends Action
{
	public ActionForward perform(ActionMapping actionMapping,
		ActionForm actionForm, HttpServletRequest request,
		HttpServletResponse response)
	throws IOException, ServletException
	{
		return null;
	}	
}
/** end WEB-INF/classes/HelloWorldAction.java **/

--
Geert Bevin                       Uwyn
"Use what you need"               Lambermontlaan 148
http://www.uwyn.com               1030 Brussels
gbevin[remove] at uwyn dot com    Tel & Fax +32 2 245 41 06

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Disable sessions

Posted by Ted Husted <hu...@apache.org>.
Struts was *not* designed with the idea of obviating use of the session 
in mind. It's quite possible that there are places where an effect of 
some operation may ask the container about a session.

The source code is available for your perusual. If there were some 
simple patches to the controller that could be applied, they could be 
considered for post 1.1. Please see Bugzilla for any submissions.

The custom tags have URL encoding built in, which relies on the concept 
of a session, and that's not going to change. If you intend to use the 
custom tags with Struts but must be totally session free, then my best 
suggestion is to look at some of the other frameworks. But I don't know 
if any of those will meet your requirements either. Google lists several

http://directory.google.com/Top/Computers/Programming/Languages/Java/Server-Side/Libraries_and_Frameworks/

-Ted.


Geert Bevin wrote:
> Hello,
> 
> I've been struggling with the 1.1-rc1 release since I didn't seem to be 
> able to disable sessions in Struts. I've read through the mailinglist 
> and tried several solutions. I also noted the responses that shortly say 
> 'Struts doesn't handle sessions, your servlet container does'. Well I 
> have the impression that Struts does manage them.
> I've briefly read through the sources and there are several locations 
> where Struts clearly starts a new session. I haven't investigated in 
> detail though. Maybe someone else can enlighten me?
> For that purpose I've tried the shortest possible testcase and even 
> removed a JSP view. Still, Struts tries to start a session.
> Below are all the related files. Does anyone have an idea what I can do 
> to completely disable sessions?
> 
> Thanks for the help,
> 
> Geert Bevin
> 
> /** begin WEB-INF/web.xml **/
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>     "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> <web-app>
> <servlet>
>     <servlet-name>action</servlet-name>
>     <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> </servlet>
> <servlet-mapping>
>     <servlet-name>action</servlet-name>
>     <url-pattern>*.do</url-pattern>
> </servlet-mapping>
> </web-app>
> /** end WEB-INF/web.xml **/
> 
> /** begin WEB-INF/struts-config.xml **/
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> 
> <!DOCTYPE struts-config PUBLIC
>           "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
>           "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
> 
> <struts-config>
> <action-mappings>
>     <action path="/hello" type="HelloWorldAction" scope="request">
>     </action>
> </action-mappings>
> </struts-config>
> /** end WEB-INF/struts-config.xml **/
> 
> /** begin WEB-INF/classes/HelloWorldAction.java **/
> import org.apache.struts.action.*;
> import javax.servlet.http.*;
> import javax.servlet.*;
> import java.io.*;
> 
> public class HelloWorldAction extends Action
> {
>     public ActionForward perform(ActionMapping actionMapping,
>         ActionForm actionForm, HttpServletRequest request,
>         HttpServletResponse response)
>     throws IOException, ServletException
>     {
>         return null;
>     }   
> }
> /** end WEB-INF/classes/HelloWorldAction.java **/
> 
> -- 
> Geert Bevin                       Uwyn
> "Use what you need"               Lambermontlaan 148
> http://www.uwyn.com               1030 Brussels
> gbevin[remove] at uwyn dot com    Tel & Fax +32 2 245 41 06
> 
> PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
> Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org