How to modify POST method in servletRequest?

115 views Asked by At

I'm using a common servlet multiple times for various classes. Now i have a requirement that differs with a small validation in using this servlet. So i thought of passing a flag like variable to servlet to meet my requirement. I've browsed to sort this out and found that i can assign variables to URLrequest.

I've set the URLRequest in Flex as follows:

var request:URLRequest = new URLRequest(UPLOAD_SERVLET_URL);
request.method = URLRequestMethod.POST;
var variables:URLVariables=new URLVariables();
variables.name="xyz";
request.data=variables;
file.upload(request);

In Java Servlet :

protected void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  // How to use the variables here...??

}

I'm going in the right direction? If so, can anyone please help me out.

If not, guide me the way how to do it !!

1

There are 1 answers

0
Rami Del Toro On BEST ANSWER

You can get parameters by accessing the getParameter method that is part HttpServletRequest API. If for example on the client a variable is called "name" then on the Servlet you can get the value of the name variable as shown below:

request.getParameter("name");