[英]How to open a new page when button is clicked on
The question is vague so allow me to clarify. 这个问题含糊不清,请允许我澄清一下。 I am developing a web app locally on eclipse and using Servlets, JSP, and an html document to design a web page.
我正在eclipse上本地开发Web应用程序,并使用Servlet,JSP和html文档来设计网页。
I have a home page which has two buttons, signup and login. 我有一个主页,其中有两个按钮,注册和登录。 I have one file, called index.jsp, which has the html configurations of the homescreen.
我有一个名为index.jsp的文件,该文件具有主屏幕的html配置。
So, when signup is clicked on, how can I get the server to load a new page with text input boxes? 因此,单击注册后,如何让服务器加载带有文本输入框的新页面?
Thanks. 谢谢。
要打开新窗口/选项卡,请使用空白目标:
<a href="SIGNUP_PAGE" target="_blank">Sign Up</a>
You can send the request from one jsp to another. 您可以将请求从一个jsp发送到另一个。 Lets say after the index.jsp you want to go to login.jsp when the button is pressed.Then create a form like this:
假设在index.jsp之后,您想在按下按钮时转到login.jsp,然后创建一个如下形式的表单:
<form action="login.jsp">
<input name="username" type="text"><br>
<input name="password" type="password">
<input type="Submit" value="Login">
</form>
Now in the login.jsp you can get the username and password using 现在,在login.jsp中,您可以使用来获取用户名和密码
String username=request.getParameter("username");
String password=request.getParameter("password");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.