aspose file tools*
The moose likes Struts and the fly likes page redirecting problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "page redirecting problem!" Watch "page redirecting problem!" New topic
Author

page redirecting problem!

ali okur
Greenhorn

Joined: Mar 08, 2010
Posts: 11
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


BookAddAction


Book.Java


bookAdd.jsp


struts_config.xml


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
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

I couldn't understand your problem properly because I think its working the way it is supposed to. You have a struts action named bookAdd, and your bookAdd.jsp has a form which has the action as bookAdd. So the form will be submitted to bookAdd action. Then that action will forward (not redirect) to data.jsp. If you want bookAdd action to redirect to data.jsp, then you should use redirect="true" in your result i.e.
(I've not worked on struts 1.x much, but I think this will work as given here)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
ali okur
Greenhorn

Joined: Mar 08, 2010
Posts: 11
thanks for reply.
You said "Then that action will forward (not redirect) to data.jsp" but it didnt.When i click to the Add button at the bookAdd.jsp it dont forward to the data.jsp it's still at the bookAdd.jsp.(When i click button i wanna forward to data.jsp) but browser changes http://localhost:8080/databaseOrnek/faces/bookAdd.jsp to http://localhost:8080/databaseOrnek/faces/bookAdd.do where am i wrong?



Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Are you using validations?? I can think of only that reason because of which struts is sending you back to the input page...
ali okur
Greenhorn

Joined: Mar 08, 2010
Posts: 11
No i didnt use validator.i did an example like thiss and it's working fine but its not icant understand where am i wrong i'm loosing my mind
ali okur
Greenhorn

Joined: Mar 08, 2010
Posts: 11
This is another example and its working fine i cant understand what is the difference between the other example why this signup example working but addbook not.in this example when i click the submit button at the signup.jsp the page forward to the signUpSuccess.jsp it works fine
please help me i will be really grateful

signupAction.java


signupform



signup.jsp



struts config


user.java



Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Please make sure that there isn't any exception at runtime when the action is called. Also add some logging or System.out.println statements in your action to see what exactly is going on, is your action even being called or not. Also if I remember correctly, if mapping.findForward(SUCCESS) returns null i.e. you return null from your execute method, struts doesn't process your request any further (although that would result in a blank page as output as opposed to the input page). Check if it is returning a valid ActionForward object...
ali okur
Greenhorn

Joined: Mar 08, 2010
Posts: 11
yes i return null from execute method i found my fault.special thanks for your advice .Now it's working fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: page redirecting problem!