Is there any possible way to send the html form data to java application without using ph开发者_StackOverflowp and asp stuff? I know we can do this using php and do it before but can i do it directly? I had used php in my previous app in which user sends his data to php form that saves it into the data base but now i want to directly get the data from the html form.PLease any idea for that?
Maybe you could consider using Java Servlets and JSP for web-based data processing ?
use the html form action attribute to specify an endpoint that will hit a java servlet running inside of a servlet container.
To handle the request in your java class, implement the HttpServlet interface.
http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpServlet.html
If you are posting from a form, them most likely you will want to implement doPost. Or you can implement service as a catch-all
Example:
<form action="/path/to/Servlet" method="post">
<input type="text" name="foo"/>
</form>
....
doPost(HttpServletRequest request, HttpServletResponse respnose) {
// set String foo to the form element named "foo"
String foo = request.getParameter("foo");
// now do whatever you need to w/ foo
}
Try Tomcat with Java Servlets. You need to:
- write a class that extends HttpServlet
- override the "doPost(HttpServletRequest, HttpServletResponse)" or "doGet(...)" methods
- write a web.xml file mapping the web page URL to the servlet handling the request
- compile and bundle everything together as required.
It'll take a little doing to get everything in the right place but it's not too hard. See the Tomcat documentation for further details. Good luck.
You can send the data by using jsp or by sending it in a link like www.google.com?q=usa and parse it on other side
精彩评论