Announcement Announcement Module
Collapse
No announcement yet.
[MVC]Add dynamic content to a view (JSP) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [MVC]Add dynamic content to a view (JSP)

    Hello everybody,

    In my app, I have a Controller who is rendered by a JSP with "static" content.
    I need to dynamically display add other static (html) content under this JSP. But I'm not sure about the best way. Can you please tell we what is the best way for your opinions ?


    1 I retrieve (read the file in a String) the html in the Controller and put it in the ModelAndView.

    2 I pass a request attribute (trough the ModelAndView) to the JSP who read the html with a pure Java fragment (<% .. %>)

    3 I pass a request attribute (trough the ModelAndView) to the JSP and use a "Helper" class to read the html and return a String.

    4 Another perfect method..

    Thanks

  • #2
    use modelandview and read it with el. ${value}.
    If you are using pure JSP, you can consider using FreeMarker to generate your output. It is faster, easier and simply better to work. No JSP, no servlets, just a simple template engine.

    Comment


    • #3
      Originally posted by bosnic View Post
      If you are using pure JSP, you can consider using FreeMarker to generate your output. It is faster, easier and simply better to work. No JSP, no servlets, just a simple template engine.
      I'm using pure JSP (with JSTL and Spring tags) but I don't know FreeMarker. Can you tell me more about how it can help me ?
      I need a Controller because it must give many attributes to the request for the first part of the view..

      Comment

      Working...
      X