How To Pass A Javascript Variable To A Java Servlet?
I want to pass a javascript variable to a java servlet. I am developing a web application. This is my html code:
Some text
And this is what i write inSolution 1:
The problem is you have the post
method in your ajax and you are trying to get it in the doGet()
of your servlet.
Use doPost
or change the method to Get
in your ajax.
Solution 2:
Try this:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String myPostVar = request.getParameter("myPostVar");
// ...
}
Post a Comment for "How To Pass A Javascript Variable To A Java Servlet?"