[?] Struts looses authenticate informations ?  
Author Message
Moreno





PostPosted: 2003-8-4 18:50:00 Top

java-programmer, [?] Struts looses authenticate informations ? Hi,

I'm trying to make my first struts application and I'm fighting with
authentication and roles.

I've only one jsp page (index.jsp) that prints authentication type ("BASIC")
and user roles.
<%
authentication+="Authentication " + request.getAuthType();

if (request.isUserInRole("ADMIN")) { role += "ADMIN; " ; }
if (request.isUserInRole("USER")) { role += "USER; " ; }
%>
<br>----------------------------------------------------
<br><%= authentication %>
<br><%= "ROLES : " + role %>
<br>----------------------------------------------------
<br>

Then there's an empty form with a "submit" button.

<html:form action="/index">
<html:submit value="SUBMIT" />
</html:form>


the execute method in action is the following :

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {

String forward = "index";
return mapping.findForward(forward);
}


When I enter my application the first time it shows exactly authentication
BASIC and ROLES : ADMIN
but when I press "submit" it shows "authentication NULL" and "ROLES : "


I'm using tomcat 4.1.18 (I also tried .24 and .27 !) and struts 1.1

WHERE' S THE ERROR ??

Thanks


---
 
himalia





PostPosted: 2003-8-5 5:32:00 Top

java-programmer >> [?] Struts looses authenticate informations ? Hi Moreno

I think the reson your getting empty values the second time around is
beacuse your setting them in request and so they get lost on the
second retrive!

I suggest you put them in session, that way the values can be
retrieved as many times as you want it to be :)

ie
session.setAuthType();
and
session.getAuthType();


"Moreno" <email***@***.com> wrote in message news:<bgldu8$u6k$email***@***.com>...
> Hi,
>
> I'm trying to make my first struts application and I'm fighting with
> authentication and roles.
>
> I've only one jsp page (index.jsp) that prints authentication type ("BASIC")
> and user roles.
> <%
> authentication+="Authentication " + request.getAuthType();
>
> if (request.isUserInRole("ADMIN")) { role += "ADMIN; " ; }
> if (request.isUserInRole("USER")) { role += "USER; " ; }
> %>
> <br>----------------------------------------------------
> <br><%= authentication %>
> <br><%= "ROLES : " + role %>
> <br>----------------------------------------------------
> <br>
>
> Then there's an empty form with a "submit" button.
>
> <html:form action="/index">
> <html:submit value="SUBMIT" />
> </html:form>
>
>
> the execute method in action is the following :
>
> public ActionForward execute(
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response) throws Exception {
>
> String forward = "index";
> return mapping.findForward(forward);
> }
>
>
> When I enter my application the first time it shows exactly authentication
> BASIC and ROLES : ADMIN
> but when I press "submit" it shows "authentication NULL" and "ROLES : "
>
>
> I'm using tomcat 4.1.18 (I also tried .24 and .27 !) and struts 1.1
>
> WHERE' S THE ERROR ??
>
> Thanks
>
>
> ---