I have an index.jsp that calls a Java controller that performs the operation and returns the result. If all the codes are sitting in the server then I am running on the Tommak server and calls the index page from my local machine. The problem is that the agent calling the controller is being reverted instead of executing the entire Java code in the server and bringing the result back. So I'm really getting
import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Public class login controller httpservlet {public login controller () {super}; }
etc. This is ajax code:
function loadRows () {var review_ID = location.search.split ('review =') [1]; $ .ajax ({url: "../src/mvcdemo/controllers/LoginController.java", type: "post", data: {"reviewID": review_ID}, success: function (data) {warning (data); ...}});
PS: Java is installed on the server, and the whole project works fine. If I run it from my local host, the problem is in the communication between the local machine and the server. The URL is running on my localhost, the URL is just "Login Controller", but when the server is running, it did not get the file, so I had to use the relative path and finally to add "java".
Edit:
I am using Web.xml to define my Servlets, this code is:
Correct me if I am wrong but do not call your JSP controller.
Solution 1 Anyway try to use this sublet 3.0 annotation (not tested):
< Code> import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; @WebServlet ("/ login") public class LoginController HttpServlet {public login controller () {super (); } @overराइड संरक्षित शून्य doPost (HttpServletRequest req, HttpServletResponse resp) {/ / whatever you want}}
then
$ Ajax ({Url: "/ login", type: "post", data: {"reviewID": review_ID}, success: function (data) {warning (data); ...}}); If you can not use servlet 3.0 annotations (which are really useful and more intuitive than web.xml),
Solution 2
> Then you have to use web.xml
You have to make sure that your web The XML is being loaded properly by the server.
No comments:
Post a Comment