JSP Tag syntax and use

Discussion in 'Java' started by SirHaplo, Feb 12, 2007.

  1. SirHaplo

    SirHaplo Guest

    Hello guys,
    i'm developing a JSP page, starting from an example.

    I'm using JPivot, a tag library for rendering OLAP results.
    Everything works well, but i need a bit of customization.

    The example code is like that :

    <jp:mondrianQuery id="queryGuaber"
    jdbcDriver="com.mysql.jdbc.Driver"
    jdbcUrl="jdbc:mysql://localhost/TMS
    catalogUri="/Guaber.xml">
    select {Referenze} on columns, {Mercato} on rows from
    Rilevazioni
    </jp:mondrianQuery>
    <jp:table id="table01" query="#{queryGuaber}"/>

    As you can see in tag tag <jp:table it use query="#{queryGuaber}. What
    is that syntax ? I mean the # and the bracket.

    In another tag it use to get a property :
    "#{table01.extensions.drillMember.enabled}"

    I want to know if I can use those objects in "normal" JSP ?
    Like that
    <%
    out.println(table01.extensions.drillMember.enabled);
    %>
    This give me an error.

    Thanks in advice.
    A little JSP noob
     
    SirHaplo, Feb 12, 2007
    #1
    1. Advertising

  2. SirHaplo

    Lew Guest

    SirHaplo wrote:
    > Hello guys,
    > i'm developing a JSP page, starting from an example.
    >
    > I'm using JPivot, a tag library for rendering OLAP results.
    > Everything works well, but i need a bit of customization.


    JSTL also sports database tags.

    > <jp:table id="table01" query="#{queryGuaber}"/>
    >
    > As you can see in tag tag <jp:table it use query="#{queryGuaber}. What
    > is that syntax ? I mean the # and the bracket.


    Are you sure the character is '#' and not '$'?

    > <%
    > out.println(table01.extensions.drillMember.enabled);
    > %>


    You absolutely never need an 'out.println' in JSP. Just put the expression in
    the HTML, or use <c:eek:ut ... />

    <p>
    ${table01.extensions.drillMember.enabled}
    </p>

    Furthermore, the "." notation in your Java scriptlet implies that you used
    public instance members, a bad practice. It is usually better to provide
    accessor methods:
    // Java, not EL
    out.println( table01.getExtensions() [drillMember].isEnabled() );

    But of course, the EL in JSP is preferable.

    By its nature, a JSP translate all its HTML into "out.println()" calls, so you
    don't have to.

    - Lew
     
    Lew, Feb 12, 2007
    #2
    1. Advertising

  3. SirHaplo

    SirHaplo Guest

    On 12 Feb, 14:59, Lew <> wrote:
    > SirHaplo wrote:
    > > Hello guys,
    > > i'm developing a JSP page, starting from an example.

    >
    > > I'm using JPivot, a tag library for rendering OLAP results.
    > > Everything works well, but i need a bit of customization.

    >
    > JSTL also sports database tags.


    Of course, but with JPivot i can visually build MDX querys and render
    the results.
    This is very useful for our customers.

    >
    > > <jp:table id="table01" query="#{queryGuaber}"/>

    >
    > > As you can see in tag tag <jp:table it use query="#{queryGuaber}. What
    > > is that syntax ? I mean the # and the bracket.

    >
    > Are you sure the character is '#' and not '$'?


    Absolutely sure.

    > > <%
    > > out.println(table01.extensions.drillMember.enabled);
    > > %>

    >
    > You absolutely never need an 'out.println' in JSP. Just put the expression in
    > the HTML, or use <c:eek:ut ... />
    >
    > <p>
    > ${table01.extensions.drillMember.enabled}
    > </p>


    Thanks a lot for the advice, but i used out.printl as an example ;)


    > Furthermore, the "." notation in your Java scriptlet implies that you used
    > public instance members, a bad practice. It is usually better to provide
    > accessor methods:
    > // Java, not EL
    > out.println( table01.getExtensions() [drillMember].isEnabled() );
    >
    > But of course, the EL in JSP is preferable.


    This is a good advice, but the code isn't mine. In future if i will
    write my own Tag Library i will follow your rule.

    Finally, no one know the meaning of #{} ?

    Thanks a lot
     
    SirHaplo, Feb 12, 2007
    #3
  4. SirHaplo

    Lew Guest

    Lew wrote:
    >> Furthermore, the "." notation in your Java scriptlet implies that you used
    >> public instance members, a bad practice. It is usually better to provide
    >> accessor methods:
    >> // Java, not EL
    >> out.println( table01.getExtensions() [drillMember].isEnabled() );
    >>
    >> But of course, the EL in JSP is preferable.


    SirHaplo wrote:
    > This is a good advice, but the code isn't mine. In future if i will
    > write my own Tag Library i will follow your rule.


    This is not related to tag libraries but Expression Language (EL) and regular
    Java syntax.

    The expression "table01.extensions.drillMember.enabled" in Java scriptlet will
    only compile if the member variables are public, which is bad practice.

    - Lew
     
    Lew, Feb 12, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean Aitken
    Replies:
    3
    Views:
    11,133
    Alex Hunsley
    Oct 21, 2004
  2. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  3. Replies:
    0
    Views:
    4,440
  4. Replies:
    5
    Views:
    484
  5. Replies:
    2
    Views:
    90
Loading...

Share This Page