Java JSP sayfasından Servlet e veri gönderme ve kullanma kodu kullanımı örneği (Java JSP send data to Servlet and use code usage example)

JSP sayfası form üzerinden jsp girdi alanlarını Servlet teki metoda gönderme işlemi

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" %>
<%@ page contentType="text/html; charset=ISO-8859-9" pageEncoding="ISO-8859-9" %> 
<html>
 <head>
  <title>My JSP page</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
  <link href="my-style.css" rel="stylesheet" type="text/css" />
  
  <script language="javascript"></script>

 <style type="text/css"></style>
</head>
<body>
  <table align="center">
   <tr>
    <td rowspan="3" style="width: 40%">
     <form action="DoMyAction" method="get">
      <div>
       <table>
        <tr>
         <td width="380">
          <span>Input01</span>
          <br />
          <input type="text" id="input01" name="input01"/>
         </td>
         <td align="center">
         </td>
        </tr>
        <tr>
         <td colspan="2">
          <span>Input02</span>
          <br />
          <textarea id="input02" name="input02" rows="3" cols="20"></textarea>
         </td>
        </tr>
        <tr>
         <td colspan="2" style="text-align:right;">
         	<span style="padding-right:25px;">
         		<input name="Git" type="submit" value="Git" />
         		<input type="button" value="Vazgeç" onClick="window.close()"> 
         	</span>
         </td>
        </tr>
       </table>
       <div id="td"></div>
      </div>
     </form>
    </td>
    <td>
    </td>
   </tr>
  </table>
</body>
</html>

Java Servlet, JSP sayfası üzerinden gelen verileri alıp işleme

package net.yazilimcity.myproject.servlet.MyServlet;

public class DoMyAction extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		try {
			String input01 = request.getParameter("input01");
			String input02 = request.getParameter("input02");	
		} catch(Exception e){
			e.printStackTrace();
		}
	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	}
}


Share on Facebook0Tweet about this on TwitterShare on Google+0Share on StumbleUpon0Share on Reddit0

1 Comment

  1. msoner says: Reply

    Teşekürler

Leave a Reply


*