I would like to thank everyone who participates in this forum. This has been an extremely valuable resource for me and many others. I look forward to one day contributing suggestions and comments as I become more knowledgeable.
Here's my recent challenge:
I have a
servlet (AddAdminServlet) who's context path is "/addtool". This servlet is the heart of my application. ALL requests are sent to this servlet and it determines the actions to take and the next page to display. Under normal conditions, if the servlet was invoked WITHOUT sending any parameters (via the URL or a submitted from), the servlet would set the appropriate variables and the user would end up at the designated "welcome page" (see code below).
Here was the dilemma: I've recently added functionality for my application to handle MultipartRequest (for file uploading). I discovered, rather quickly, that when submitting MultipartRequest there was no straightforward way of "grabbing" the parameters which were submitted with the form, even though they were present (e.g. req.getParameter("cmd") would return a null value). I realized that I would have to parse the request to find the desired values. I wrote the code to do all of my parsing, access the database, create the entries, handle the errors, etc. It works fine (I was kinda proud of myself!). BTW, that servlet was being tested having its own context path, say, "/dopost", for example.
I didn't want it in its own context path because I wanted to call it from the heart of the application, AddAdminServlet. I made the necessary changes and integrated the DoPost into the rest of the application.
Now, my reasoning was, when the AddAdminServlet receives a request where the parameter value "cmd" is null ( req.getParameter("cmd") ) it must be a MultipartRequest, call DoPost, if a file is not present or the desired format, or any other non-desirable scenario let DoPost set the appropriate variable and return the user to the "welcome page".
Here's the PROBLEM: When firing up my
test environment for the first time (
TomCat 3.2) and entering "http://localhost:8080/addtool", the page just sits there displaying "Opening page at
http://localhost:8080/addtool ..." for an INDEFINITE period of time.
The application now only works if I enter: "http://localhost:8080/addtool/?cmd=main-menu" which accesses the "welcome page". Once I've accessed that page, I can navigate fine. Functionality returns to normal, including file uploading (MultipartRequest), etc. Wonderful.
The goal with this application was to have "http://localhost:8080/addtool" in the URL at all times. This was achievable until I recently directed DoPost to handle all null "cmd" values.
I must add that once I am "in" the application, entering "http://localhost:8080/addtool" in the URL and pressing "enter" goes back to "Opening page at
http://localhost:8080/addtool ..." for an INDEFINITE period of time.
It appears to me that my DoPost can only handle legitimate MultipartRequest and "freezes up" when it receives a URL without ANY parameters?
Any thoughts?
HERE IS THE AddAdminServlet CODE:
HERE IS THE DoPost CODE (ONLY FOR REFERENCE!):