wood burning stoves 2.0*
The moose likes Servlets and the fly likes How do I get my JSP to call a servlets doPost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How do I get my JSP to call a servlets doPost " Watch "How do I get my JSP to call a servlets doPost " New topic
Author

How do I get my JSP to call a servlets doPost

Martin Lawrence
Greenhorn

Joined: Oct 20, 2000
Posts: 14
Hi All,
how do I get the following jsp code to call the doPost method
on my servlet. Every time I call the servlet it call's it's
doGet method. From what I understand the doGet method has a limit
to the number of bytes it can receive. Since the data that I will
be sending is large I would like to call the servlets doPost method.
<%@page import="java.io.*";%>
<%!
//Main fields passed to servlet
//=============================
String apiKey ="doSomeThing";
String xmlString ="This contains a large amount of data";
%>
<HTML>
<HEAD>
<TITLE>
My Attempt To call the doPost method on servlet ClientToEJB,
instead it calls doGet
</TITLE>
</HEAD>
<BODY bgcolor="white">
<center>
<FORM>
<small><a href='/ClientToEJB?APIKEY=<%=apiKey%>&XMLKEY=<%=xmlString%>'>Click To Send Data To Servlet</a></small>
</FORM>
</BODY>
</HTML>
mars76
Ranch Hand

Joined: Nov 30, 2000
Posts: 30
Hi..
Set the method=POST in the form tag and submit the page to the Servlet you have in the JavaScript after doing all the validations...

Sateesh
srivatsan srinivasan
Greenhorn

Joined: Jun 08, 2001
Posts: 26
hi,
you r passing values in the query string,so the dogetmethod is called by default.inside the doGet method call doPost(req,res)
which will call the dopost method.
Marya Doery
Greenhorn

Joined: Dec 27, 2000
Posts: 15
Just to expand a bit on your question:
The page you sent shouldn't work at all. The <FORM> tag *requires* an ACTION parameter, which you haven't specified. So you're not actually submitting to the servlet, you're GETting from it via the HREF tag.
Here's a page about forms from the horse's mouth: http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#h-17.3
Also this is about form submission: http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#submit-format
Whether or not you use javascript, if you're using the POST method, you'll have to use <INPUT> tags to send the form variables that you want passed to the servlet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get my JSP to call a servlets doPost
 
Similar Threads
How pass the selected values of the Combo box to the servlet....
File not found error
HTTP method GET is not supported by this URL
How pass the selected values of the Combo box to the servlet....
Servlet getParameter