You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ramil Mirhasanov <ra...@dolunay.com.tr> on 2004/04/19 09:41:10 UTC

OT: session of previously logined users is retrieved

Hi,

I encountered a problem while testing my web application in the internet.
When user is authorized, the parameters of this user are stored in the
"UserInfo" object and put to the session, as the below:

                    /** LoginAction.java**/

  if (errorDetected == false){
           UserInfo userInfoBean = userDBBean.ParseUserInfo(username,
verify);
           userInfoBean.setU_KulAdiNosu(verify);
           HttpSession session = req.getSession();
           session.setAttribute("user", userInfoBean );
           logined = "true";
           session.setAttribute("logined", logined );
...
During the tests, when you login to the application, surprisibgly the
session of previously logined user is retrieved.

The UserInfo object is retreived later in jsp page :
UserInfo userInfoBean = ( UserInfo )session.getAttribute("user");

Thank you in advance, for your help!
Ramil.


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


Re: Buffering the ouput of a JSP page within an action

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Struts has a <bean:include> tag - not used it myself, but the docs say it
performs an internal dispatch to a component or URL and stores the response
in a bean. Maybe you could use that as part of a solution.

http://jakarta.apache.org/struts/userGuide/struts-bean.html#include


I have a simple tag (StoreTag) which does something similar, except you
embed the jsp stuff you want in the tag. So you could set up a jsp with this
tag and then in your action use the RequestDispatcher to include the jsp and
put the output into a bean. Something like:


 ------SamplePage.jsp-----
 <custom:store name="myForm" property="samplePage" scope="session">
     ------ format your jsp stuff here -----
 </custom:store>


-------in your Action.execute()-------
// Get formatted email content
RequestDispatcher rd =
servlet.getServletContext().getRequestDispatcher("myJspPage.jsp");
rd.include(request, response);
String samplePage= form.getSamplePage();

In this example, you would need so set up the "samplePage" as a property in
your ActionForm.

----------StoreTag Source-----------------
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import org.apache.struts.util.RequestUtils;
import org.apache.commons.beanutils.BeanUtils;

public class StoreTag extends BodyTagSupport {

protected String name = null;
protected String property = null;
protected String scope = null;

public StoreTag() {
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setProperty(String property) {
this.property = property;
}
public String getProperty() {
return property;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getScope() {
return scope;
}
public int doAfterBody() throws JspException {
String value = null;
if (bodyContent != null) {
value = bodyContent.getString().trim();
}
if (property == null) {
pageContext.setAttribute(name, value, RequestUtils.getScope(scope));
} else {
// find the bean
Object bean = RequestUtils.lookup(pageContext, name, scope);
if (bean == null)
throw new JspException("Cannot find bean '"+name+"' in scope '"+scope+"'");
try {
BeanUtils.setProperty(bean, property, value);
}
catch (Exception ex) {
throw new JspException("Error setting property '"+property+"' on bean
'"+name+"' in scope '"+scope+"': "+ex);
}
}
return (SKIP_BODY);
}
public void release() {
name = null;
property = null;
scope = null;
}
}

----- Original Message ----- 
From: "Amine Bousta" <am...@freesurf.fr>
Sent: Monday, April 19, 2004 11:00 AM


> Hello,
>
> I'm trying to write a struts action that could save in a database and
> send by e-mail the output of a JSP page.
> This JSP page needs attributes values that are stored in the session
> context. In other words, I need ServletContext of the struts action and
> the JSP page to be the same.
>
> I first tried to use the Java "URL" object to perform this action but it
> creates a separate ServletContext.
>
> I didn't find any solution to this issue on the internet.
> Does anybody can help me?...
>
> Amine



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


RE : Buffering the ouput of a JSP page within an action

Posted by Amine Bousta <ab...@lxsolutions.com>.
Thank you very much.
It seems that Velocity is a good solution for my pb.
I just have now to replace variables of the template by object values
stored in my session within my struts action (because I have to save the
result text in the database as well)

Thank you again for this link

Amine

-----Message d'origine-----
De : Wiebe de Jong [mailto:wiebedj@shaw.ca] 
Envoyé : lundi 19 avril 2004 20:51
À : 'Struts Users Mailing List'
Objet : RE: Buffering the ouput of a JSP page within an action

Check out Matt Raible's solution to templated-email using Velocity. It
is
good and I intend to use it for this purpose.

http://www.theserverside.com/blogs/showblog.tss?id=SpringVelocityEmail

Wiebe

-----Original Message-----
From: Amine Bousta [mailto:amine.bousta@freesurf.fr] 
Sent: Monday, April 19, 2004 3:01 AM
To: 'Struts Users Mailing List'
Subject: Buffering the ouput of a JSP page within an action

Hello,

I'm trying to write a struts action that could save in a database and
send by e-mail the output of a JSP page.
This JSP page needs attributes values that are stored in the session
context. In other words, I need ServletContext of the struts action and
the JSP page to be the same.
 
I first tried to use the Java "URL" object to perform this action but it
creates a separate ServletContext.

I didn't find any solution to this issue on the internet.
Does anybody can help me?...

Amine



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


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





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


RE: Buffering the ouput of a JSP page within an action

Posted by Wiebe de Jong <wi...@shaw.ca>.
Check out Matt Raible's solution to templated-email using Velocity. It is
good and I intend to use it for this purpose.

http://www.theserverside.com/blogs/showblog.tss?id=SpringVelocityEmail

Wiebe

-----Original Message-----
From: Amine Bousta [mailto:amine.bousta@freesurf.fr] 
Sent: Monday, April 19, 2004 3:01 AM
To: 'Struts Users Mailing List'
Subject: Buffering the ouput of a JSP page within an action

Hello,

I'm trying to write a struts action that could save in a database and
send by e-mail the output of a JSP page.
This JSP page needs attributes values that are stored in the session
context. In other words, I need ServletContext of the struts action and
the JSP page to be the same.
 
I first tried to use the Java "URL" object to perform this action but it
creates a separate ServletContext.

I didn't find any solution to this issue on the internet.
Does anybody can help me?...

Amine



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


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


Buffering the ouput of a JSP page within an action

Posted by Amine Bousta <am...@freesurf.fr>.
Hello,

I'm trying to write a struts action that could save in a database and
send by e-mail the output of a JSP page.
This JSP page needs attributes values that are stored in the session
context. In other words, I need ServletContext of the struts action and
the JSP page to be the same.
 
I first tried to use the Java "URL" object to perform this action but it
creates a separate ServletContext.

I didn't find any solution to this issue on the internet.
Does anybody can help me?...

Amine



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