通过单击后退按钮转到jsp页面 [英] go to jsp page by hitting back button

查看:56
本文介绍了通过单击后退按钮转到jsp页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2 jsp pages and one Servlet.我正在通过servlet从数据库中获取数据,并将结果发送到显示结果的result.jsp页.但是我想通过单击back buttonresult.jsp中添加Back button,我想转到index.jsp,但是问题是,每当有消息出现Confirm form submission时,我都单击后退"按钮,这很烦人.我如何避免此Confirm form submission?也许随着servlet中处理的完成而来.

I have 2 jsp pages and one Servlet. I am fetching data from database by servlet and sending result to result.jsp page where i am displaying result. But i want to add a Back button in result.jsp , by clicking back button i want to go to index.jsp, but problem is when i am clicking back button everytime a message is coming Confirm form submission and it is irritating me. How can i avoid this Confirm form submission? perhaps it is coming as processing is done in servlet.

index.jsp

index.jsp

<form method="post" action="Student">

<input type="text" name="studentname"/>
<input type="submit" value="search"/>

</form>

学生servlet

 String student_name=request.getParameter("studentname");

  -------fetching data from database------------
  -------------------sending to result.jsp------

  String nextJSP = "/result.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request,response);

result.jsp

result.jsp

 //displaying data here

<form action="index.jsp">

 <input type="submit" value="back"/>// a back button is here which is going to index.jsp   
</form>

编辑

result.jsp转到下一页result1.jsp,如下所示

From result.jsp i am going to another page result1.jsp like below

result.jsp中,我写了以下内容:

In result.jsp i have written the following:

<a  href="result1.jsp.jsp?a code=<%out.println(student_name);%>"><%out.println(student_name);%></a>

通过单击上面的超链接,我转到了result1.jsp

By clicking the above hyperlink i went to result1.jsp

我想在此处(在result1.jsp中)添加一个后退按钮,单击后我要对result.jsp进行操作,但是单击后退按钮时,每次都得到Confirm form submission.我在result1.jsp

I want to add a back button here(in result1.jsp) and after clicking i want to do to result.jsp, but when clicking back button i am getting Confirm form submission every time. I have written the following in result1.jsp

<input type="button" value="Back" onclick="javascript:history.go(-1)">

仍然我收到该消息Confirm form submission.我如何避免这种情况?我想直接转到result.jsp而不显示此消息.怎么可能?

Still i am getting that message Confirm form submission. How can i avoid this? I want to go to result.jsp directly with out this message. How is it possible?

推荐答案

您还可以使用它返回上一页

you can also use this to go one page back

<button type="button" name="back" onclick="history.back()">back</button>

这篇关于通过单击后退按钮转到jsp页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆