I’m writing a Struts action class from which I generate some HTML content and add it to a field in ActionForm. How can I display it in the JSP file.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would consider to use the request object instead of modifying the ActionForm. You may use the logic and bean taglibs in the JSP and try to separate the HTML content and put it all in the JSP.
As example, you can use in your action:
And in your JSP something like this:
But I think it would be a better aproach to leave of the html code to the JSP who is the responsible of that. An action has to do other things and is a good design to maintain these tasks separate.
Consider this for your action:
And this for your JSP:
This way you centralize all the html code generation on your JSP files and free the action of that burden.