Help on querystring with struts on websphere app server
Hi,
I am using WAS 6.1 for my application . currently i m facing problem with querystring. I have a struts tiles defined in my application. Now when i try using querystring (request.getQueryString() ) on Tomcat 5.0 , i get the currect value but if i use the same code on webshere 6.0 the code request.getQueryString() returns nulll.. Please help urgently on this Issue.....
Thanks,
Bhusan Shrama
// I use webphere 6.1, it works
protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println(arg0.getQueryString());
java.io.PrintWriter out = arg1.getWriter();
out.println(arg0.getQueryString());
}
Hey,
what evilknighthksays might work, but still is a bit dodgy, may not work on another server.
What you've gotta do to fix it up is to create a FormBean with attributes same name as the queryString you're sending.
Look at my example , I'm sending a queryString like this : myfile?stringId=apple&action=editand this is the form I have for it :
package struts.beans;
import org.apache.struts.validator.ValidatorForm;
/**
*
* @author u3958283
*/
public class IdAction extends ValidatorForm {
private String stringId ;
private int intId ;
private String action ;
/** Creates a new instance of IdAction */
public IdAction() {
}
public String getStringId() {
return stringId;
}
public void setStringId(String stringId) {
this.stringId = stringId;
}
public int getIntId() {
return intId;
}
public void setIntId(int intId) {
this.intId = intId;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}
This is how my struts configuration for that form is :
<form-beans>
. ... some stuff ....
<form-bean name="idAction" type="struts.beans.IdAction"/>
</form-beans>
<action path="/editUser"
type="struts.action.GetUser"
name="idAction"
scope="request"
validate="true"
parameter="edit"
>
</action>
Doing it this way makes everything nice and dandy and you will be able to user multiple webservers ...
Hope this helps.
Cheers,
shukuboy