javascript onclick jsp value passing to servlet

javascript onclick jsp value passing to servlet

Program: MyJsp.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
function document123() {
	var append_input = document.getElementById("txt").value;
	// My_Workouts is the project name.
<label>Enter the text to pass Servlet   </label>
<input type="text" id="txt" ></input>
<button type="button" onclick="document123()">Go to Servlet!</button></div>

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public MyServlet() {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String input_value = request.getParameter(&quot;nav&quot;);
		System.out.println(&quot;In servlet   &quot;+input_value);




1,764 total views, 6 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.