这是我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org /xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"version="3.1">
<display-name>Frontend</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Webapp Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.restify.frontend;org.codehaus.jackson.jaxrs</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Webapp Application</servlet-name>
<url-pattern>/reporter/*</url-pattern>
</servlet-mapping>
</web-app>
这是我的第一个servlet:servlet的名称:响应
@WebServlet({ "/Response", "/reportsto" })
public class Response extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
.....
我的第二个servlet,即Response1:
@WebServlet({ "/Response1", "/resp" })
public class Response1 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
.....
Set<Map.Entry<Object,Object>> s2=map1.entrySet();
PrintWriter out1=response.getWriter();
out1.println("<html>"+
"<form action=\"./reportsto\" method=\"get\">"+
"<input type=\"cancel\" value=\"cancel\" name=\"cancel\">\n\">"+
"</form>"+);
So from the servlet Response1 I need to goto the previous page that is servlet1 Response onclicking the cancel button.How can this be done please advice.
实际上我的servlet1响应将输出为:
Number User Id Username Count
1 A12354 Anagha R 0
2 M12345 Madhusudan S 1
我的第二个Servlet Response1显示:
1 CHARgska Validating
在servlet2中,单击时需要有一个取消按钮,将我带回到上一页,即servlet1
答案 0 :(得分:1)
单击Cancel
按钮会将用户带到先前访问的页面。
out1.println("<html>"+
"<form action=\"./reportsto\" method=\"get\">"+
"<input onclick=\"window.history.go(-1); return false;\" type=\"button\" value=\"Cancel\" />"+
"</form>"+);