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

2

5

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?

Deration answered 25/7, 2012 at 5:26 Comment(1)
If you want to display something dont return null.Akkadian
S
6

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.

Sami answered 25/7, 2012 at 5:35 Comment(4)
Can you tell me exact what will happen when we return null in action classDeration
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.Sami
If i want to display the some text after returning the null how can i doneDeration
You define a forward to "some_text.jsp" and put your text in there. Or you output the text before you return.Sami
P
1

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

Philosophize answered 12/2, 2013 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.