Having a single method handle both GET and POST is *bad*. Really bad. It likely violates the HTTP specification, and will get you into trouble with HTTP handling components that treat them differently. The simple rule to follow is: do not do it.
NetBeans is the usual culprit for this sort of bug; it should be taken out back and shot for that.
Ulf Dittmer wrote:It likely violates the HTTP specification, and will get you into trouble with HTTP handling components that treat them differently.
Actually, in JEE, an incoming request invokes the HttpServlet service() method, which looks at the the request type, and invokes doGet() if it's a GET and doPost() if it's a POST.
The actual parameters are normalized, so if you make doGet and doPost invoke a common method, you're OK as long as it doesn't attempt to reference resources not appropriate for the request type.
On the other hand, it really isn't a good practice overall. Too much chance that as time goes by someone will start adding request-type specific conditionals into the common method.
One reason why I might combine the two would be something where I'd be doing a "ping" request as a GET with limited parameters, but a POST for a full-function operation or one that had the potential for extended-length parameters. But on the whole, it would be better to have separate handlers for stuff like that.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
2. Servlet Send that make and http request and when it get the response pass the control to another Servlet "Receive"
3. Servlet Receive print the cdsOutput request parameter
My problem is that I only would like to show the JSP when the cdsOutput parameter is not null but debbuging I can see that the first time doGet is called I see the JSP with the text csOutput is null but the second time that this method is called cdsOutput is not null but the JSP is not displayed.
How could I do it?
Thanks in advance!
posted 6 years ago
but the JSP is not displayed
I'm confused. The only difference the parameter "cdsOutput" makes is in what gets returned as the page content. It has no influence over displaying any JSP. In fact, the Receive servlet method does not use any JSP. Based on that code, how where you expecting any JSP to be displayed?
What also confuses me is how "cdsOutput" could ever have a non-null value, since neither the form submit in the HTML page, nor either of the two servlets, ever set any value for it.
May be you should use variable as in "Receive" servlet and then append the values in it.
And there is no JSP displaying the output after you "Receive" servlet. It is just the servlet flusing the output stream and giving the response.
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...