2010-10-15 21 views
0

這是deleteProduct.jsp頁面代碼。 問題是隻有轉發標記和DB操作很好。 我用轉發標記adminProducts.jsp 但結果是不正確的。 它顯示adminProducts.jsp頁面內容,但地址欄顯示deleteProduct.jsp 最新問題和我該如何解決這個問題?jsp:轉發標記無法正常工作?

<%@ page contentType="text/html;charset=UTF-8"%> 
<html> 
<%@ page import="org.j2os.shine.jconnection.JDBC" %> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 
    <title>delete product</title> 
    </head> 
    <body> 
    <% 
     String id = request.getParameter("id"); 
     out.print(id); 
     JDBC mydb = new JDBC(); 
     mydb.login("com.mysql.jdbc.Driver","jdbc:mysql://localhost/rouyesh", "username", "password", true); 
     mydb.executeSQLQuery("delete from products where id=" + id); 
     mydb.commit(); 
    %> 

    <jsp:forward page="adminProducts.jsp"></jsp:forward> 
    </body> 
</html> 
+0

瞭解的servlet取代

<jsp:forward page="adminProducts.jsp"></jsp:forward> 

。 – BalusC 2010-10-16 00:16:47

回答

3

轉發沒有問題。轉發合同是根本不改變URL作爲服務器端操作。如果您想要地址欄顯示正確的地址,請執行重定向。

+0

我應該使用什麼標籤?代替前進通過我的paramiters? – 2010-10-16 00:06:24

+0

問題取決於您必須通過多少個參數。如果數字很小,那麼您應該將它們作爲GET參數傳遞。否則,您必須向前傳遞,因爲GET有可以傳遞的參數限制。對於這種情況,請使用一些服務器內存來在請求之間存儲參數,或者嘗試重寫URL – Fazal 2010-10-16 19:09:03

2

response.sendRedirect("adminProducts.jsp");