Hello Jomy,
now the sense of Struts is to separate the different concerns. Please see also
http://struts.apache.org/primer.html#mvc.
I don't know if it makes sense to generate HTML inside a java class instead of producing it in a JSP. As Tom wrote
it might be uncommon to generate HTML as it might be difficult to maintain such HTML. Of course it is possible to write
a java class generating HTML
. So you can
test it. Please write a
Servlet class which will produce HTML as a result.
To make it more interesting just generate a huge HTML page where you write into some variables let us say using StringBuffer
or StringBuilder. Then try to do a complete redesign of that web page changing the generator class. Then you might
recognize that it would be better to put it all into a JSP page and all the rest into a model. The sense of MVC is to disjoin
the three concerns namely model, view, controller.
If you like you can present your code so that people can speak about it and you could learn
On the other hand there are
lots of different example codes using struts.