Browsed by
Tag: servlet

JSP Servlet with AJAX Example

JSP Servlet with AJAX Example

JSP Servlet with AJAX Example Ajax is a great feature implemented almost in all the websites in some way. It gives really a very good user interface, since things are loading/populating without refresh. It is commonly used in username availability checking, register/login page db level/business level validations etc. We are going to use Ajax with JSP and servlet to calculate the EMI payable amount by giving amount, month and interest rate in single screen(without refreshing). Requirements: 1. Include jQuery library…

Read More Read More

666 total views, no views today

clicked value passing from one jsp to another jsp

clicked value passing from one jsp to another jsp

Create the first jsp named main.jsp and paste the below code,   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <html> <head> <title>agn</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta name="GENERATOR" content="Rational Application Developer"> </head> <body> <!–<iframe src="http://www.w3schools.com"> <p>Your browser does not support iframes.</p> </iframe> –> <a href="/ToCapitalLetter?a=javadomain">click me</a> </body> </html> Create a servlet named ToCapitalLetter.java and paste the below code, import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation…

Read More Read More

545 total views, no views today

Passing clicked value from jsp to jsp/servlet

Passing clicked value from jsp to jsp/servlet

Passing value from jsp to jsp/servlet: We can pass the value from jsp to servlet using, request.getParameter(“text”); //servlet code to get the jsp value where text is the name of the input fields (text field). Passing clicked value from jsp to jsp/servlet: We have to pass the clicked value as get parameter in the href link like below, <a href=”/Myservlet?input=javadomain”> MyServlet is the name of the servlet. Servlet code: request.getParameter(“input”); So javadomain will be passed from jsp to servlet. In…

Read More Read More

1,930 total views, no views today

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" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Javadomain.in</title> </head> <script type="text/javascript"> function document123() { var append_input = document.getElementById("txt").value; document.location.href="/My_Workouts/MyServlet?nav=’"+append_input+"’"; // My_Workouts is the project name. } </script> <body> <label>Enter the text to pass Servlet </label> <input type="text" id="txt" ></input> <button type="button" onclick="document123()">Go to Servlet!</button></div> </body> </html> MyServlet.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(&quot;/MyServlet&quot;) public class MyServlet extends HttpServlet…

Read More Read More

1,162 total views, no views today

Passing values from servlet to jsp

Passing values from servlet to jsp

Step 1: ServletCall.jsp   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Javadomain.in</title> </head> <body> Click the below button to call the servlet, then servlet will print the value in the display.jsp file <br> <br> <form action="ServletValues"> <input type="submit"> </form> </body> </html>   Step 2: ServletValues.java   import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/ServletValues") public class ServletValues extends HttpServlet {…

Read More Read More

786 total views, no views today