[英]jsp forward tag is not working in jsp
我制作了一個login page
,但轉發標簽不起作用,它產生了我無法找出的錯誤。
我使用訪問數據庫,點擊登錄按鈕后,它會檢查,如果用戶已經注冊,那么頁面應該轉發下一頁,但事實並非如此。
這是我的代碼:
<form action="login.jsp" method="get">
<table>
<tr></tr>
<td><br>
<label>EmailID:</label>
</td>
<td>
<input type="text" name="emailid" maxlength="50" size="30">
</td>
<tr></tr>
<td><br>
<label>Password:</label>
</td>
<td>
<input type="password" name="passwordid" maxlength="50" size="30">
<p>
</p>
</td>
<tr></tr>
<td></td>
<td><input type="submit" value="sign in"></center></td>
<%
try
{
String existemail="registration",existpass="12345";
ResultSet rs, rs1;
String emailid1=request.getParameter("emailid");
String passwordid1=request.getParameter("passwordid");
if(emailid1.length()!=0 && passwordid1.length()!=0)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:collegep");
Statement st = conn.createStatement();
rs=st.executeQuery("select password from collge where
email='"+emailid1+"'");
while(rs.next())
{
existpass= rs.getString(1);
}
if(existpass.equals(passwordid1))
{
<jsp:forward page=
"afterlogin.html" />
}else
{ %> invalid combination of email and password<%
}
}
else
{` %>
<div id="error">all field must be filled.</div>
<%
}
}
catch(Exception e){}
%>
請嘗試從以下位置更改:
<jsp:forward page:
到:
<jsp:forward page=
好像你使用了不合適的 Scriplet 標簽(<% %>)..close scriptlet end tag(%>) 在你的<jsp:forward page="afterlogin.html"/>
上方
所有 java 代碼都應該只在 Scriplet Tag 中..和它之外的 html 代碼..做這個改變
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.