You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Hertz <jh...@patriot.net> on 2003/11/12 11:03:15 UTC

Utter Newbie Question

I'm making using struts for more or less than first time.

I read the FAQ on how to handle logins to an application and I'm left with 
one question:

Why stop a storing a Boolean in the session to determine "logged-inness"? 

Why not just store the (validated) "User" object in the session and check for 
it's presence? That way, if it's there, one can utilize the data in the User 
object for whatever sordid little purpose said developer comes up with.

Is this a good idea?

If so, how do I go about doing this in the view? (I told you I was a newbie!).

I mean using bean:write tags of the "User" object seems straightforward 
enough, but what about the List of "Children" objects that is part of 
the "User" object?

TIA

-Joe

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


Re: Utter Newbie Question

Posted by Arne Brutschy <ma...@studserv.uni-leipzig.de>.
Wednesday, November 12, 2003, 11:03:15 AM, you wrote:
JH> Why stop a storing a Boolean in the session to determine "logged-inness"?

JH> Why not just store the (validated) "User" object in the session and check for
JH> it's presence? That way, if it's there, one can utilize the data in the User
JH> object for whatever sordid little purpose said developer comes up with.

That excactly what I'm doing. At the login, the business logic checks
if the credentials supplied were right. If so, the user object will be
stored in the session. In that way, I can easily access all the user's
properties without doing a lookup all the time. You might run into
memory problems if you have a lot of simultanous logged in users
and/or big user objects. But that not the case for me. Additionally,
I'm storing a list of the users group membership in the session. So I
can do fast permission checks based on this list (always doing a
lookup for every groups is expensive).


JH> I mean using bean:write tags of the "User" object seems straightforward
JH> enough, but what about the List of "Children" objects that is part of
JH> the "User" object?

I don't really understand. I'm using code like this to access the
user object:

            <c:choose>
              <%-- check if the users object is stored in the session--%>
              <c:when test="${empty sessionScope.user}">
                <%-- it's not, present a "you're not logged in" message --%>
                <span id="error"><bean:message key="login.header.unauthd"/></span><br>
              </c:when>

              <%-- the user is logged in --%>
              <c:otherwise>
                <%-- present a welcome message like "Welcome, John Doe." --%>
                <bean:message key="login.header.welcome"/>, ${sessionScope.user.name}.

                <%-- display the logout form --%>
                <html:form action="login.do">
                  <html:hidden property="dispatch" value="logout"/>
                  <%-- the requested page parameter is used to return to this page after logout --%>
                  <html:hidden property="requestedPage" value="${pageContext.request.servletPath}"/>
                  <html:submit><bean:message key="login.button.logout"/></html:submit>
                </html:form>
              </c:otherwise>
            </c:choose>

As you can see, I read and display the user's name with
${sessionScope.user.name}.

But I have to warn you, I'm a struts newbie too.. :)

Regards,
Arne Brutschy


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


Re: how to read request attribute

Posted by Stack Buffer <bl...@yahoo.com>.
hi,
 
you can try the  following JSTL tags, which can be used with the Struts-el library
 
<c:out value="expression" default="expression" escapeXml="boolean"/>
 
<c:set var="name" scope="scope" value="expression">

if thats what ur looking for 

"Garg Raman (SDinc)" <ra...@smartdatainc.com> wrote:
Hi,
can anyone tell me I want to show value of my

request.setAttribute("varName",varName);

in my jsp page created in struts,
do we have any method to show the value wihtout using jsp tags

I want to show it in "paramId="id", paramProperty paramName??
I have want a link like
Edit.do?id=5






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



---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

how to read request attribute

Posted by "Garg Raman (SDinc)" <ra...@smartdatainc.com>.
Hi,
can anyone tell me I want to show value of my

request.setAttribute("varName",varName);

in my jsp page created in struts,
do we have any method to show the value wihtout using jsp tags
<%=request.getAttr..... %>
I want to show it in "<html:link" tag what will be value of
paramId="id",  paramProperty paramName??
I have want a link like
Edit.do?id=5






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


Re: Dynamic bean in a result list

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
Ok,
I've found the answer : Mapped properties
http://jakarta.apache.org/struts/faqs/indexedprops.html


----- Original Message ----- 
From: "Ovidiu EFTIMIE" <oe...@assemblee-nat.fr>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 12, 2003 11:47 AM
Subject: Dynamic bean in a result list


> Hi,
> I have a jsp page where I must diplay a list of results like this
> <logic:present  name="DOCUMENTS">
>     <logic :iterate id='laliste' name='DOCUMENTS'>
>
>        <tr>
>
>            <td><bean :write name='liste' property='author'></td>
>
>            <td><bean :write name='liste' property='title'></td>
>
>            <td><bean :write name='liste' property='domain'></td>
>
>        </tr>
>
>     </logic :iterate>
>
>    </logic:present>
>
> </logic :present>
>
> DOCUMENTS is an Array List which contains JavaBeans. The thing is that I want
to
> use a dynamic JavaBean, so I could have an ArrayList of objects like this
> public class DynamicOT implements Serializable{
>
> private HashMap property;
>
>
> public DynamicOT(){
>
> property = new HashMap();
>
> }
>
> public void setProperty(String nm, String val){
>
> property.put(nm,val);
>
> }
>
> public String getProperty(String nm){
>
> String str = (String) property.get(nm);
>
> return str;
>
> }
>
> }
>
> But then how could I retrive them in my jsp page ?
> Using
>  <td><bean :write name="liste" property="property('author')"></td>
> would be enough?
>
> Has anyone an idee of how I could do this ?
>
> Thanx in advance,
> Ovidiu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Dynamic bean in a result list

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
Hi,
I have a jsp page where I must diplay a list of results like this
<logic:present  name="DOCUMENTS">
    <logic :iterate id='laliste' name='DOCUMENTS'>

       <tr>

           <td><bean :write name='liste' property='author'></td>

           <td><bean :write name='liste' property='title'></td>

           <td><bean :write name='liste' property='domain'></td>

       </tr>

    </logic :iterate>

   </logic:present>

</logic :present>

DOCUMENTS is an Array List which contains JavaBeans. The thing is that I want to
use a dynamic JavaBean, so I could have an ArrayList of objects like this
public class DynamicOT implements Serializable{

private HashMap property;


public DynamicOT(){

property = new HashMap();

}

public void setProperty(String nm, String val){

property.put(nm,val);

}

public String getProperty(String nm){

String str = (String) property.get(nm);

return str;

}

}

But then how could I retrive them in my jsp page ?
Using
 <td><bean :write name="liste" property="property('author')"></td>
would be enough?

Has anyone an idee of how I could do this ?

Thanx in advance,
Ovidiu


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