【发布时间】:2019-07-16 09:55:03
【问题描述】:
我正在使用 json 格式的 JQuery 从login.html 向 servlet 发送数据到 servlet,在匹配记录后,我想打开一个新页面 home.html,我还想将数据发送到 home.html:
DTORegisteration dto=new DTORegisteration();
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
String id = req.getParameter("id");
String password = req.getParameter("password");
System.out.println("id "+id);
System.out.println("password "+password);
dto.setId(id);
dto.setPassword(password);
String str=new ServiceRegisteration().getDetails(dto);
JSONObject json=new JSONObject();
if(str.equals("success")) {
try { json.put("welcome", "welcome"); json.put("name",
DAORegisteration.name);
}catch(JSONException e) { e.printStackTrace(); }
pw.print(json);
}
}
【问题讨论】:
标签: html mysql database servlets servlet-3.0