Forums Register Login

doPost Servlet called by wget needs addHeader logic

+Pie Number of slices to send: Send
I invoke my doPost Servlet using a wget --post-data. This works fine and the response for OK and Failure are working. However, I cannot correctly code the addHeader statement. Will the header text be generated as output automatically?
Any ideas?
.........
String h_mainname="StatusAdmin";
String h_name="StatusUpdate";
........
.......
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{

response.setContentType("text/html");
// the next line is incorrect
public void addHeader(java.lang.String h_name, java.lang.String h_val);

String lname = request.getParameter("lname");
String task = request.getParameter("task");

response .setStatus(response.SC_OK, "All is Well");
}
+Pie Number of slices to send: Send
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
+Pie Number of slices to send: Send


That is the signature of the method addHeader in the HttpServletResponse interface, not valid code for a doPost method.

If you don't understand the difference you need to get back to basics.

Bill
+Pie Number of slices to send: Send
Well, the comment was accurate anyway
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1839 times.
Similar Threads
how to connect the HTML form with my servlet
how to keep register page data if register fails
Servlet help
having problem in connecting HTML form to servlet
HTTP Status 404 ERROR
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:19:32.