for (var i = 0; i < GoData.length; i++)
{
var user = GoData[i];
var row = table.insertRow(-1);
var cell = row.insertCell(-1);
var link = usb.create('a');
link.innerHTML = user['Incident'];
link.href = 'http://werk.intranet=' + user['Incident'];
usb.on(link, 'click', (function(u) { return function() { usb.userRequest(u, true); }})(user['Incident']));
cell.appendChild(link)
cell = row.insertCell(-1);
cell.innerHTML = user['Title'];
}
SecondServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(); //create a session
session.setAttribute("sessionname", "sessionvalue");
out.println("Session value = " +session.getAttribute("sessionname"));
out.println("Session ID is " +session.getId());
out.println(session.isNew()); //checks whether the session is new or old
out.println(session.getMaxInactiveInterval()); //Default 30 minutes 1800secs
//session.invalidate();
Cookie ck= new Cookie("Cookiename", "cookievalue");
response.addCookie(ck);
out.println("<html>");
out.println("<body>");
out.println("<form action=SecondServlet>");
out.println("<input type=submit />");
out.println("</form>");
out.println("</body>");
out.println("</html>");
}
我试图创建一个重定向到另一个servlet类的提交按钮。但提交没有被创建我如何更改它。这两个servlet类都可以单独运行。
答案 0 :(得分:0)
你可以像提交按钮
一样添加动作public void HttpServletResponse.sendRedirect(String location)
抛出IOException
答案 1 :(得分:0)
您可以尝试以下代码:
response.sendRedirect("home.html"); // Redirects to home
或者
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);