Cannot retrieve mapping for action /j_security_check
Hello all, I looked in the archives but couldn't find an answer to my question. I'd like to convert my working form-based login page to use struts' html form taglib. I get the following Exception when trying to load login.jsp: javax.servlet.ServletException: Cannot retrieve mapping for action /j_security_check I was hoping someone could help out with the conversion. This works: form name=login action=j_security_check method=POST table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdinput type=text name=j_username size=20/td /tr tr th align=rightPassword:/th tdinput type=password name=j_password size=20/td /tr tr align=center td colspan=2input type=submit value=Login/td /tr /table /form This does not: html:form action=j_security_check focus=j_username table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdhtml:text property=j_username//td /tr tr th align=rightPassword:/th tdhtml:password property=j_password//td /tr tr align=center td colspan=2html:submitLogin/html:submit/td /tr /table /html:form I'm hoping all I need to do is add an entry in struts-config.xml, but I'm not sure what that entry should be. Any help would be appreciated. -ryan
RE: Cannot retrieve mapping for action /j_security_check
You will need to add the Action mapping in your struts-config.xml file. You will also need the form-bean mapping that your form will use to pass the form data to the action class. Here is an example. form-beans !-- Loin form bean -- form-bean name=loginForm type=com.dextera.examples.forms.LoginForm/ /form-beans action-mappings !-- Process a user login -- actionpath=/login type=com.dextera.examples.actions.LoginAction name=loginForm scope=request input=/login.jsp forward name=success path=/home.jsp/ /action-mappings All in all you will need the following: 1. A form bean to carry the data 2. Action servlet to perform your action 3. Form bean declaration in struts-config 4. Action mapping in struts-config Good luck. Jay Patel 972-701-9773 972-849-0373 Mobile [EMAIL PROTECTED] -Original Message- From: Shriver, Ryan [mailto:[EMAIL PROTECTED]] Sent: Friday, August 24, 2001 2:26 PM To: '[EMAIL PROTECTED]' Subject: Cannot retrieve mapping for action /j_security_check Hello all, I looked in the archives but couldn't find an answer to my question. I'd like to convert my working form-based login page to use struts' html form taglib. I get the following Exception when trying to load login.jsp: javax.servlet.ServletException: Cannot retrieve mapping for action /j_security_check I was hoping someone could help out with the conversion. This works: form name=login action=j_security_check method=POST table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdinput type=text name=j_username size=20/td /tr tr th align=rightPassword:/th tdinput type=password name=j_password size=20/td /tr tr align=center td colspan=2input type=submit value=Login/td /tr /table /form This does not: html:form action=j_security_check focus=j_username table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdhtml:text property=j_username//td /tr tr th align=rightPassword:/th tdhtml:password property=j_password//td /tr tr align=center td colspan=2html:submitLogin/html:submit/td /tr /table /html:form I'm hoping all I need to do is add an entry in struts-config.xml, but I'm not sure what that entry should be. Any help would be appreciated. -ryan
RE: Cannot retrieve mapping for action /j_security_check
If you are using container-managed authentication, why use a Struts FormBean? You can get the username from the container using the getCallPrincipal() method of HttpServletRequest to get the logged in user's principal. If you absolutely want to use an ActionForm via Struts, keep reading. You will need to create a FormBean with 2 fields of type String. -- Code for LoginForm.java -- package com.yourcompany.yourapp.LoginForm; //import statements here public class LoginForm extends ActionForm { protected String j_username; protected String j_password; public LoginForm() { super(); } public void setJ_username(String j_username) { this.j_username = j_username; } public String getJ_username() { return j_username; } public void setJ_password(String j_password) { this.j_password = j_password; } public String getJ_password() { return j_password; } //other methods for ActionForm } -- End Code -- You will also have to supply the name and type parameters in the html:form tag -- code for login.jsp -- html:form name=loginForm action=j_security_check method=POST type=com.yourcompany.yourapp.LoginForm scope=session %-- Other html elements --% /html:form -- end code -- You will also need to declare your LoginForm inside struts-config.xml -- code for struts-config.xml -- struts-config form-beans form-bean name=loginForm type=com.yourcompany.yourapp.LoginForm/ !-- other form-bean declarations -- /form-beans !-- other struts-config elements -- /struts-config -- end code -- That should be it, just make sure you setup your web.xml file to use form-based login. James Hicks -Original Message- From: Shriver, Ryan [mailto:[EMAIL PROTECTED]] Sent: Friday, August 24, 2001 2:50 PM To: 'Jay Patel '; ''[EMAIL PROTECTED]' ' Subject: RE: Cannot retrieve mapping for action /j_security_check Thanks for the quick reply but this seems like too much work just to get some consistency across my .jsp forms. I would think there would be a way for struts to let forms posted to j_security_check pass through to the servlet container instead of the normal Action classes. I want the container, not Struts, to do my authentication/authorization. Thanks for the help though. -ryan -Original Message- From: Jay Patel To: '[EMAIL PROTECTED]' Sent: 8/24/2001 3:41 PM Subject: RE: Cannot retrieve mapping for action /j_security_check You will need to add the Action mapping in your struts-config.xml file. You will also need the form-bean mapping that your form will use to pass the form data to the action class. Here is an example. form-beans !-- Loin form bean -- form-bean name=loginForm type=com.dextera.examples.forms.LoginForm/ /form-beans action-mappings !-- Process a user login -- actionpath=/login type=com.dextera.examples.actions.LoginAction name=loginForm scope=request input=/login.jsp forward name=success path=/home.jsp/ /action-mappings All in all you will need the following: 1. A form bean to carry the data 2. Action servlet to perform your action 3. Form bean declaration in struts-config 4. Action mapping in struts-config Good luck. Jay Patel 972-701-9773 972-849-0373 Mobile [EMAIL PROTECTED] -Original Message- From: Shriver, Ryan [mailto:[EMAIL PROTECTED]] Sent: Friday, August 24, 2001 2:26 PM To: '[EMAIL PROTECTED]' Subject: Cannot retrieve mapping for action /j_security_check Hello all, I looked in the archives but couldn't find an answer to my question. I'd like to convert my working form-based login page to use struts' html form taglib. I get the following Exception when trying to load login.jsp: javax.servlet.ServletException: Cannot retrieve mapping for action /j_security_check I was hoping someone could help out with the conversion. This works: form name=login action=j_security_check method=POST table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdinput type=text name=j_username size=20/td /tr tr th align=rightPassword:/th tdinput type=password name=j_password size=20/td /tr tr align=center td colspan=2input type=submit value=Login/td /tr /table /form This does not: html:form action=j_security_check focus=j_username table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdhtml:text property=j_username//td /tr tr th align=rightPassword:/th tdhtml:password property=j_password//td /tr tr align=center td colspan=2html:submitLogin/html:submit/td /tr /table /html:form I'm hoping all I need to do is add an entry in struts-config.xml, but I'm not sure what that entry should be. Any help would be appreciated. -ryan
RE: Cannot retrieve mapping for action /j_security_check
Thanks for the quick reply but this seems like too much work just to get some consistency across my .jsp forms. I would think there would be a way for struts to let forms posted to j_security_check pass through to the servlet container instead of the normal Action classes. I want the container, not Struts, to do my authentication/authorization. Thanks for the help though. -ryan -Original Message- From: Jay Patel To: '[EMAIL PROTECTED]' Sent: 8/24/2001 3:41 PM Subject: RE: Cannot retrieve mapping for action /j_security_check You will need to add the Action mapping in your struts-config.xml file. You will also need the form-bean mapping that your form will use to pass the form data to the action class. Here is an example. form-beans !-- Loin form bean -- form-bean name=loginForm type=com.dextera.examples.forms.LoginForm/ /form-beans action-mappings !-- Process a user login -- actionpath=/login type=com.dextera.examples.actions.LoginAction name=loginForm scope=request input=/login.jsp forward name=success path=/home.jsp/ /action-mappings All in all you will need the following: 1. A form bean to carry the data 2. Action servlet to perform your action 3. Form bean declaration in struts-config 4. Action mapping in struts-config Good luck. Jay Patel 972-701-9773 972-849-0373 Mobile [EMAIL PROTECTED] -Original Message- From: Shriver, Ryan [mailto:[EMAIL PROTECTED]] Sent: Friday, August 24, 2001 2:26 PM To: '[EMAIL PROTECTED]' Subject: Cannot retrieve mapping for action /j_security_check Hello all, I looked in the archives but couldn't find an answer to my question. I'd like to convert my working form-based login page to use struts' html form taglib. I get the following Exception when trying to load login.jsp: javax.servlet.ServletException: Cannot retrieve mapping for action /j_security_check I was hoping someone could help out with the conversion. This works: form name=login action=j_security_check method=POST table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdinput type=text name=j_username size=20/td /tr tr th align=rightPassword:/th tdinput type=password name=j_password size=20/td /tr tr align=center td colspan=2input type=submit value=Login/td /tr /table /form This does not: html:form action=j_security_check focus=j_username table border=3 cellpadding=2 cellspacing=2 align=center tr th align=rightUsername:/th tdhtml:text property=j_username//td /tr tr th align=rightPassword:/th tdhtml:password property=j_password//td /tr tr align=center td colspan=2html:submitLogin/html:submit/td /tr /table /html:form I'm hoping all I need to do is add an entry in struts-config.xml, but I'm not sure what that entry should be. Any help would be appreciated. -ryan