Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

JSP Tag syntax and use

Thread view: 
SirHaplo - 12 Feb 2007 11:12 GMT
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
Lew - 12 Feb 2007 13:59 GMT
> 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:out ... />

  <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
SirHaplo - 12 Feb 2007 14:12 GMT
> > Hello guys,
> > i'm developing a JSP page, starting from an example.
[quoted text clipped - 3 lines]
>
> 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);
[quoted text clipped - 6 lines]
>      ${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
[quoted text clipped - 3 lines]
>
> 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
Lew - 12 Feb 2007 15:01 GMT
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
[quoted text clipped - 3 lines]
>>
>> 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.