General discussion

  • Creator
  • #2328463

    Overcome jsp:include limitations


    by Mark W. Kaelin ·

    Tell us what you think about our tip on overcoming jsp:include limitations with the JSTL import tag.

All Comments

  • Author
    • #3605305

      Avoiding jsp:include

      by kparks ·

      In reply to Overcome jsp:include limitations

      I’ve avoided using jsp:include and opted for an in-house written “http include” style in our jsp base classes. But, I’m still not sure about jslt for the simple fact that I don’t want the “View” layer to be too heavy.

      • #3604700

        Shades of #include in C/C++

        by stephen mcconnell ·

        In reply to Avoiding jsp:include

        This smacks of the #include found in C/C++. Is this where we want to be going in JSP’s?

        • #3603824

          erm yes

          by bayard-generationjava ·

          In reply to Shades of #include in C/C++

          in answer to where we want JSPs to go, I would
          normally envision some form of including being at the
          heart of most web sites.

          It’s the perfect way to apply a theme to a system without
          going the whole hog to a content management system
          that pieces together pages on the fly.

          I could see an argument for having ‘typed’ includes, like
          a tag for ‘header’, a tag for ‘footer’ with special abilities,
          but to lose the concept of including seems like a big

          Maybe I’m misunderstanding.

      • #3603820

        fated to happen

        by bayard-generationjava ·

        In reply to Avoiding jsp:include

        While I am not against your feelings that the view layer
        could get too heavy, it seems that the JSP spec is going
        in this direction. JSTL will either roll into the JSP spec
        someday or become a tight sibling, always found in the
        same place.
        If you’re just looking for an improved include, ie)
        matching your internal ones, then you can just use that
        aspect of jstl when the time comes. Admittedly at the
        moment it would be an addition of a new library, so I
        would advise against leaping to it, but instead keep an
        eye out and prepare for JSP 2.0 so you can deprecate/
        modify your in-house stuff accordingly.

    • #3604712

      But can I nest variables?

      by noosh ·

      In reply to Overcome jsp:include limitations

      Does this handle variable scoping any better than jsp:include? I’d love to be able to use included .jsp snippets as methods for outputting particular kinds of data, for example one that takes a class “Employee” object and formats it in a standard way. Right now all I can do is the equivalent of “x=thisData; include employee.jsp”, i.e. using global variables. Takes me back to BASIC programming.

      outputs lists as alternating white/grey rows where I pass in the data in an array

      • #3577998

        Am I missing something…

        by talkingstone ·

        In reply to But can I nest variables?

        Have you considered using: to pass parameters? note that the xml style jsp include allows you to add dynamic (<%= %>) values to any number of listed parameters.

        I may be winging it with this suggestion as it’s been some time since I tried this.


        • #3603829


          by bayard-generationjava ·

          In reply to Am I missing something…

          My view exactly. jsp:param appears to be all this reader
          needs. JSTL has the param syntax and so matches
          jsp:param at least. I need to check up to see if there are
          any advantages in the spec beyond jsp:param. Mainly
          as I can’t recall if jsp:param is limited to Strings or not.

Viewing 1 reply thread