티스토리 뷰

반응형
package org.kodejava.example.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ParameterCheck extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {

        // Check if username parameter exists
        if (req.getParameterMap().containsKey("username")) {
            String username = req.getParameter("username");
        }

        // Check if password parameter exists
        if (req.getParameterMap().containsKey("password")) {
            String password = req.getParameter("password");
        }
    }
}

 

반응형