CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Servlet Syntax

  1. #1
    Join Date
    Sep 1999
    Posts
    10

    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




  2. #2
    Join Date
    Jul 1999
    Location
    Metro DC
    Posts
    32

    Re: Servlet Syntax

    Why can't you just use req.getParameter(xxx)

    . That seems a bit more simple to do.




  3. #3
    Join Date
    Sep 1999
    Posts
    10

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured