• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clarrifications on EL function

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to EL in JPS. i try to run the following EL function.



/*********************/
DiceRoller.tld
/**********************/

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<tablib >

<tlib-version>1.2</tlib-version>
<jspversion>2.0</jspversion>

<uri>DiceRoller</uri>

<function>
<name>rollIt</name>
<function-class>com.study.DiceRoller</function-class>
<function-signature>int roll()</function-signature>
</function>
</tablib>


/******************************************/
Jsp file to call the EL function
/******************************************/

<%@ page isELIgnored="false" %>
<%@ taglib prefix="mine" uri="DiceRoller" %>

${mine.rollIt()}



/******************************************/
DiceRoller.java
/******************************************/

package com.study;

public class DiceRoller {

public static int roll() {

return (int) (Math.random());
}

}


i am getting the following error.

The function rollIt must be used with a prefix when a default namespace is not specified
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

${mine.rollIt()}


Is a period the correct delimiter to follow a namespace?
 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I am new to this EL function, just i copied the example given in HeadFirstJSP&Servlet.

Please help me to solve this issue.

i don't know about the namespace?
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am new to this EL function, just i copied the example given in HeadFirstJSP&Servlet.



Hi There,
You have not copied it correctly. Please go check it again. To give you a head's up about namespace,it is nothing but a nick name you use as a prefix to call every function defined in the taglib.

For example: In case of jsp is the nick name and the forward is a public static function defined some where and mapped accordingly in the taglib. But, you should observe that, they have used collon operator to call a function in the taglib.Whereas you have used period operator.

So, try the following. It should word.

This is what exactly Bear meant to say.
[ May 24, 2008: Message edited by: Prasad Tamirisa ]
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javaranch suggests to use UBB Code tags to post code. Please use them from the next time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic