Skip to content
Permalink
Browse files

Added doGet and doPost

  • Loading branch information...
tattwei46 committed Jul 9, 2019
1 parent 2a08c4d commit d7e40ce56fc73e965e05e33cd39bca4ca2b9c212
@@ -0,0 +1,22 @@
package com.davidcheah.webapplication.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/search")
public class SearchServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("GET request received " + request.getParameter("item"));
}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("POST request received " + request.getParameter("item"));
}
}
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action = "/WebApplication/search">
Search for anything<input type="text" name="item" />
<input type="submit" />
</form>
</body>
</html>

0 comments on commit d7e40ce

Please sign in to comment.
You can’t perform that action at this time.