thanks for reply.
" BookAdd.jsp is defined as input for bookAdd action." is it wrong??i think
it must be like that.
when i click submit button at the bookAdd.jsp i wanna forward to the data
jsp but it dont there is no action i'm still at the bookAdd.jsp where i am
wrong
<action input="/bookAdd.jsp" name="BookAddForm" path="/bookAdd"
scope="request" type="paket.BookAddAction" >
<forward name="success" path="/data.jsp"/>
</action>
Paweł Wielgus wrote:
>
> Hi Tesla,
> validation problem?
> BookAdd.jsp is defined as input for bookAdd action.
>
> Best greetings,
> Pawel Wielgus.
>
> 2010/3/13, tesla <[email protected]>:
>>
>> 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
>> --
>> View this message in context:
>> http://old.nabble.com/page-redirecting-problem-tp27886004p27886004.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://old.nabble.com/page-redirecting-problem-tp27886004p27888959.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]