-
Servlet Syntax
Consider:
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException
{
java.util.Hashtable formData =
HttpUtils.parsePostData(req.getContentLength(),
req.getInputStream());
String[] name = (String[])formData.get("name");
String[] email = (String[])formData.get("email");
addSignee(name[0], email[0]);
doGet(req,res);
}
Question: I know all methods in the HttpUtils class are static; therefore one doesn't have to instantiate the HttpUtils class to use them. But how come object formData of java.util.Hashtable didnt have to be instantiated since the methods are NOT static? ie. new Hashtable()?
Thanks
Dino
-
Re: Servlet Syntax
Why can't you just use req.getParameter(xxx)
. That seems a bit more simple to do.
-
Re: Servlet Syntax
The author of the code used Hashtable's get method because it returns a string array, not a string. An HttpServletRequest object may contain multiple values for a single NAME attribute. The get method returns string array with all the NAMEd values. Why? I'm not sure as of yet why he chose it but ill find out after im done relaxing :). Still i dont know why 'new' was not used to instantiate an object of class Hashtable to call the get method. :(
Dino