我有一個網絡項目與NetBeans的Maven。我正在使用Glassfish & MySQL。我的Java servlet不工作在maven(netbeans)
這是我的註冊畫面 newUserScreen
點擊「TAMAM」之後,我想借此從網站註冊到我的數據庫,但我只是看到我的服務器URL,並沒有發生任何事情。 emptyUserServletUrlScreen
這是我的servlet:
package tr.kasim.cc.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import tr.kasim.cc.app.Application;
import tr.kasim.cc.util.GeneralUtil;
import tr.kasim.cc.model.SignUp;
/**
*
* @author SelmanKasim
*/
@WebServlet(urlPatterns = {"/userservlet"})
public class SignUpUsersServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
protected void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = null;
try {
out = new PrintWriter(resp.getOutputStream());
String action = req.getParameter("action");
if ("addUser".equals(action)) {
addUser(req, resp);
}
} catch (Exception ex) {
Logger.getLogger(SignUpUsersServlet.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("hata var agacim");
} finally {
if (out != null) {
out.flush();
out.close();
}
}
}
public void addUser(HttpServletRequest req, HttpServletResponse resp) throws Exception, IOException {
String loginName = req.getParameter("loginName");
String password = req.getParameter("password");
String eMail = req.getParameter("eMail");
String userName = req.getParameter("userName");
String userDate = req.getParameter("userDate");
String userJob = req.getParameter("userJob");
String userTelephone = req.getParameter("userTelephone");
String userCity = req.getParameter("userCity");
String userGenderId = req.getParameter("userGenderId");
SignUp sign_up = new SignUp(null,loginName,password,eMail,userName,userDate,userJob,userTelephone,userCity,userGenderId);
Application.getApp().getMainService().addUser(sign_up);
resp.sendRedirect("./userList.jsp");
}
}
這是我註冊的jsp:
<%--
Document : userKayit
Created on : 24.Mar.2017, 17:42:39
Author : SelmanKasim
--%>
<%@page import="java.util.List"%>
<%@page import="tr.kasim.cc.app.Application"%>
<%@page import="tr.kasim.cc.model.SignUp"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Kayit</title>
<link rel="stylesheet" type="text/css" href="css/index.css"></link>
</head>
<body><center>
<p class="title">Yeni User Kayit</p>
<form method="post" action="userservlet">
<input type="hidden" name="action" value="addUser"/>
<table>
<tr>
<td>Giris Adi:</td>
<td><input type="text" name="girisAdi"/></td>
</tr>
<tr>
<td>Sifre:</td>
<td><input type="text" name="sifre"/></td>
</tr>
<tr>
<td>eMail:</td>
<td><input type="text" name="eMail"/></td>
</tr>
<tr>
<td>Kullanici Adi:</td>
<td><input type="text" name="kullaniciAdi"/></td>
</tr>
<tr>
<td>Kullanici Kayit Tarihi:</td>
<td><input type="text" name="kullaniciKayitTarihi"/></td>
</tr>
<tr>
<td>Kullanici Cinsiyeti:</td>
<td><input type="text" name="kullaniciCinsiyeti"/></td>
</tr>
<tr>
<td>Kullanici İsi:</td>
<td><input type="text" name="kullaniciIsi"/></td>
</tr>
<tr>
<td>Kullanici Telefonu:</td>
<td><input type="text" name="kullaniciTelefonu"/></td>
</tr>
<tr>
<td>Kullanici Sehri:</td>
<td><input type="text" name="kullaniciSehri"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Tamam"/></td>
</tr>
</table>
<br/><br><br>
<a href="index.jsp">Ana Sayfaya Dön</a><br>
</center>
</form>
</body>
</html>
現在我不能採取任何登記。 你覺得呢?我的錯誤在哪裏/什麼是?
你有任何web.xml嗎?如果是的話,添加它 – developer
不,我沒有任何web.xml – superior