-1
나는 JSP와 함께이 양식 필드를 처리 할 :Null 포인터 예외가 발생하는 폼 처리 중입니까?
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.log(Level.INFO, "Creating User!!!");
logger.info("Request: " + req.toString());
PrintWriter out = resp.getWriter();//Here I get the null Pointer exception
String email = req.getParameter("email");
String password = req.getParameter("password");
logger.info(email + password);
try {
user.insert(email, password);
Log.info("Inserted: " + email + " " + password);
} catch (Exception e) {
String msg = DAOUser.getErrorMessage(e);
out.print(msg);
}
}
:
<div class="control-group">
<!-- Text input-->
<label class="control-label" for="input01">Email:</label>
<div class="controls">
<input name="email" placeholder="email"
class="input-xlarge" type="text"
value="<%=request.getParameter("email")%>">
</div>
</div>
<div class="control-group">
<!-- Text input-->
<label class="control-label" for="input01">Password:</label>
<div class="controls">
<input name="password" placeholder="password"
class="input-xlarge" type="text"
value="<%=request.getParameter("password")%>">
</div>
</div>
내가이
NullPointerException
내 서블릿 방법을 먹으 렴 얻을 제출을 누르면.
이 널 포인터 예외를 수정하는 방법은 무엇입니까?
UPDATE
내 서블릿 :
public class DAOServletUser extends HttpServlet {
private static final long serialVersionUID = 6820994892755862282L;
private static final Logger logger = Logger.getLogger(DAOServletUser.class.getCanonicalName());
/**
* Get the entities in JSON format.
*/
public DAOServletUser() {
super();
}
public IDAOUser user;
/**
* Create the entity and persist it.
*/
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.log(Level.INFO, "Creating User!!!");
logger.info("Request: " + req.toString());
if(resp==null) {
System.out.println("Respond is NULL!!!");
}
PrintWriter out = resp.getWriter();//Here I get the null Pointer exception
String email = req.getParameter("email");
if(email==null) {
System.out.println("email is null");
} else {
System.out.println("email is NOT null");
}
String password = req.getParameter("password");
if(password==null) {
System.out.println("password is null");
} else {
System.out.println("password is NOT null");
}
logger.info(email + "::" + password);
try {
user.insert(email, password);
Log.info("Inserted: " + email + " " + password);
} catch (Exception e) {
String msg = DAOUser.getErrorMessage(e);
out.print(msg);
}
}
정확한 오류 메시지 (stracktrace)를 줄 수 있습니까? 그 문제가 무엇인지 정확히 알기가 어렵습니다. –
어떤 라인이 에러를 던지고 있는지 알려주십시오 - 예외의 스택 트레이스는 정보를 갖습니다 – Bohemian
죄송합니다. 스택 트레이스가 없습니다. 'Error : java.lang.NullPointerException' 페이지 만 가져옵니다. – maximus