Take the 2-minute tour ×

What will happen if action class returns the null in struts?

If it displays null jsp page,then if you want to diplay something how can we achieve it?

share|improve this question
If you want to display something dont return null. –  Subir Kumar Sao Jul 25 '12 at 5:32
add comment

2 Answers

up vote 4 down vote accepted

If the Action returns null, no further processing/forwarding will be done, and the response so far will be sent to the client.

Useful if you just want to send error responses, or create the output directly in the Action instead of forwarding to a view (which of course you are discouraged to do).

If you want to display something, don't return null.

If the Struts code is somehow beyond your control (but why would that happen, even if you don't want to touch the source you could subclass for example), I guess you could install a ServletFilter to inject some additional post-processing.

share|improve this answer
Thanks for your reply –  user1550575 Jul 25 '12 at 6:11
Can you tell me exact what will happen when we return null in action class –  user1550575 Jul 25 '12 at 6:21
Well, nothing happens ;-) When your Action returns, Struts checks the configured forward and continues processing there. If there is no more forward, Struts is done. –  Thilo Jul 25 '12 at 6:24
If i want to display the some text after returning the null how can i done –  user1550575 Jul 25 '12 at 6:35
You define a forward to "some_text.jsp" and put your text in there. Or you output the text before you return. –  Thilo Jul 25 '12 at 6:38
add comment

I think one can take advantage of making AJAX calls to the server and populating data in client browser without reloading the page.

share|improve this answer
add comment

Your Answer


