tags:

views:

17

answers:

2

this is deleteProduct.jsp page code. the problem is only the forward tag and the DB operation works good. i used the forward tag to go to adminProducts.jsp but the result is not correct. it shows adminProducts.jsp page content but the address bar shows deleteProduct.jsp whats the problem and how can i fix this ?

<%@ 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>
+2  A: 

There is no problem with forward. The contract of forwarding is to not change the URL at all as its a server side operation. If you want address bar to show the correct address, do a redirect.

Fazal
what tag should i use ? stead of forward to pass my paramiters ?
Ammar
The issue depends on how many parameters you have to pass. if number is small then you should pass them as GET parameters. Otherwise you would have to pass forward as GET has a limit of parameters you can pass. For that case, either use some server memory to store parameter between requests or may be try URL rewrite
Fazal
+1  A: 

replace

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

with

response.sendRedirect("adminProducts.jsp");
Ammar