Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

page redirecting problem

tesla

2010-03-13

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi

I have a basic struts project i can't redirect my jsp page to another.But i
did the similar example before that it was working but know it's not.
My problem is bookAdd.jsp dont redirect to the data.jsp it's redirecting to
the bookAdd.do please help!Thanks

Here is my BookAddForm

   
public class BookAddForm extends org.apache.struts.action.ActionForm {
   
  private String book_title;
  private String book_description;
  private int book_price;

//Getters Setter

public void reset(ActionMapping mapping,HttpServletRequest request){

    this.book_description=null;
    this.book_title=null;
    this.book_price=0;


}


BookAddAction

   
public ActionForward execute(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response)
       throws Exception {
    BookAddForm bookAddForm= (BookAddForm) form;
    Book book=new Book();
   
book.addBook(bookAddForm.getBook_title(),bookAddForm.getBook_description(),bookAddForm.getBook_price());

    return mapping.findForward(SUCCESS);
     
      }


Book.Java

   
public class Book {

  private String title;
  private String description;
  private int price;

 Connection con ;
 Statement ps;
 ResultSet rs;

  public void addBook(String title,String description,int price) throws
SQLException
  {
     try
    {
       Class.forName("com.mysql.jdbc.Driver");
       con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/logintest_development","root","pass");
       ps = (Statement) con.createStatement();
        String sql = "insert into books(title,description,price)
values('"+title+"','"+description+"''"+price+"')";
        ps.executeUpdate(sql);
    }
  catch (Exception e)
  {
   System.out.println("Error Data : " + e.getMessage());
  }

    con.close();
     
  }


bookAdd.jsp

   
<body>
    <h1>Add Book!</h1>

    <html:form action="/bookAdd" method="post" >
       Book's Title:<html:text property="book_title" size="30"
maxlength="30"/><br>
       Book's Descripton:<html:textarea property="book_description"
/><br>
       Book's Price:<html:text property="book_price" size="30"
maxlength="30"/><br>
          <html:submit>Add</html:submit>
    </html:form>
  </body>


struts_config.xml

 
<form-bean name="BookAddForm" type="paket.BookAddForm"/>
 
<action input="/bookAdd.jsp" name="BookAddForm" path="/bookAdd"
scope="request" type="paket.BookAddAction" >
      <forward name="success" path="/data.jsp"/>
  </action>
 


when i click submit button at the jsp file it shows me the same page can't
redirect to data.jsp but my browser changes bookAdd.jsp to bookAdd.do
i cant understand why it is
--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.