I'm rewriting a CGI application into Java/Struts so I'm still a newbie at this and am having little luck finding answers/examples to simple things online such as how to pass query string parameters to my form bean in a URL (GET) instead of in a jsp form using struts tags. Basically I'm trying to call an action I defined in a URL. Everything seems to be working fine except that I can't get the params from my query string:
URL: /t.do?sId=XXXX struts-config.xml: <form-bean name="tForm" type="packageInfo.TForm" /> <action path = "/t" type = "packageInfo.TAction" name = "tForm" scope = "request" input = "/pages/t.jsp" > <forward name="TStoreSuccess" path="/pages/t.jsp" /> </action> TForm.java: private String sId = null; public String getSId() { return sId; } public void setSId(String string) { sId = string; } TAction.java: public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //These "messages" come from the ApplicationResources.properties file MessageResources messages = getResources(request); TForm tForm = (TForm) form; ActionErrors errors = new ActionErrors(); //Check to see if we're storing a url String sId = tForm.getSId(); if (!(sId == null) || !(sId.length() < 1)) { //Forward control to the specified success URI return (mapping.findForward("TStoreSuccess")); } else { errors.add("NO_URL", new ActionError("packageInfo.t.NO_URL")); saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } } t.jsp: <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html:html locale="true"> <head> <title><bean:message key="t.jsp.title"/></title> <html:base/> </head> <body bgcolor="white"><p> <html:errors/><p> <logic:present name="packageInfo" scope="request"> <h2> <bean:message key="t.jsp.stored"/>!<p> </h2> </logic:present> <logic:present name="tForm" property="sId"> <bean:write name="sId" scope="request"/> </logic:present> </body> </html:html> I always get the html:errors even when I pass it the parameter in the URL string. If I hard code private String sId = "XXX", I don't get the error, but my <logic:present name="tForm" property="sId"> ... </logic:present> doesn't seem to evaluate since I don't see the variable get printed out on the page. Can someone please help with how to make this work? Hopefully I'll get the hang of it after this and won't have to ask such basic questions.