Re: jstl doesn't work

2005-10-22 Thread Christian Taylor

Hi Michael,

Did you include the necessary taglib directives at the beginning of your 
JSP? For example, to use the core taglib as you are doing:


[EMAIL PROTECTED] prefix=c uri=http://java.sun.com/jsp/jstl/core%

This needs to be included at the top of any JSP using the taglib. If you 
already know this, I apologize. It was the only thing I could think of 
that you didn't mention. Hope this helps.


-Christian

michael Muttai wrote:

Why do I get ${customers.firstName} when I use the following codes in 
a jsp file?


c:forEach var=customers items=${requestScope.customers}
tr
tdc:out value=${customers.firstName}//td
...
/tr
/c:forEach

I use JBoss 4.0.3. I include jstl.jar and standard.jar under 
web-inf/lib and some *.tld files under web-inf.


Any help is appreciated.




Michael

_
On the road to retirement? Check out MSN Life Events for advice on how 
to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to print an int with a c:out tag?

2005-08-03 Thread Christian Taylor
I've never actually included my JSTL taglibs this way. I have just put
jstl.jar and standard.jar in WEB-INF/lib. The TLD files are contained in
standard.jar and should be automatically recognized by the container
(Tomcat or otherwise). All I have to do then is include this line in any
JSP:

[EMAIL PROTECTED] uri=http://java.sun.com/jsp/jstl/core; prefix=c%

(modify for the sql, fmt, xml and function taglibs of course)

I wonder if trying to put your own entry in web.xml and use separate TLD
files is causing problems?

 -Christian

-Original Message-
From: Marius Botha [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 03, 2005 6:52 AM
To: 'Tag Libraries Users List'
Subject: RE: How to print an int with a c:out tag?

Thanks guys,

I tried that and got a new error (below). I will probably just go the
scriptlet route for now as maybe I have an old or incorrect JAR
somewhere.
Can any one tell me where the TagLib for FN is?

What I did:
1. Changed web-app ... as per example.
2. Included FN taglib in my web.xml file as I do with the other ones I
use:
  taglib
taglib-uri/tags/fn/taglib-uri

taglib-locationhttp://java.sun.com/jsp/jstl/functions/taglib-location

  /taglib
  taglib
taglib-uri/tags/jstl-core/taglib-uri
taglib-location/WEB-INF/c.tld/taglib-location
  /taglib

Then I get File http://java.sun.com/jsp/jstl/functions; not found,
OR, If I don't import the taglib in my web.xml file and just try to use
it, I
get:
The attribute prefix fn does not correspond to any imported tag
library

Thanks again for you patience, you've been a great help and I've learned
quite a bit.

Thanks,

Marius

-Original Message-
From: Christian Taylor [mailto:[EMAIL PROTECTED]
Sent: 02 August 2005 07:59
To: Tag Libraries Users List
Subject: Re: How to print an int with a c:out tag?


My next guess was going to be one thing mentioned on the page Murray
links to below. Regardless of whether you are using Tomcat 5, JSTL 1.1
and JSP 2.0... if your web.xml doesn't say it's a servlet 2.4 app it
will revert to Servlet 2.3/JSP 1.2 (and trying to use JSTL 1.1 with JSP
1.2 probably introduces many other problems...). As the page says, make
sure your webapp element starts like this:

web-app xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4

Otherwise the container will assume the servlet 2.3 spec and EL will not
be allowed outside of JSTL (1.0) tags. The fn:length() function I
originally mentioned is part of JSTL 1.1 anyway so it sounds like you
just need to make sure everything is configured for the current specs
and you should be good. Hope that will fix it up for you.

 -Christian

Murray Steele wrote:

 Perhaps this page might provide the solution?

 http://www.oreillynet.com/cs/user/view/cs_msg/32931

 Wrong taglib uri's or wrong webapp specification in your web.xml.

 Muz


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to print an int with a c:out tag?

2005-08-02 Thread Christian Taylor
Hi Marius,

Check out the fn:length() function, this is what you are looking for.
size() is a method and you cannot call methods directly from JSTL (only
getters and setters), but the fn taglib provides a function for length
of Collections and strings. See the JSTL 1.1 documentation for more
information, but basically fn:length() is what you are looking for:

c:out value=${fn:length(myList)}/

Hope this helps.

 -Christian

Marius Botha wrote:

Hi there,

Just a basic question. I am trying to print out the size() of a List, like
the tag below.

c:out value=${myList.size}/

But I am getting the following error: An error occurred while evaluating
custom action attribute value with value ${myList.size}: The .
operator was supplied with an index value of type java.lang.String to be
applied to a List or array, but that value cannot be converted to an
integer. (null)

Can the c:out tag not print int's or is it that I am calling size() which
does not have a getter/setter method? Please help.

Thanks,

Marius

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to print an int with a c:out tag?

2005-08-02 Thread Christian Taylor
My next guess was going to be one thing mentioned on the page Murray
links to below. Regardless of whether you are using Tomcat 5, JSTL 1.1
and JSP 2.0... if your web.xml doesn't say it's a servlet 2.4 app it
will revert to Servlet 2.3/JSP 1.2 (and trying to use JSTL 1.1 with JSP
1.2 probably introduces many other problems...). As the page says, make
sure your webapp element starts like this:

web-app xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4

Otherwise the container will assume the servlet 2.3 spec and EL will not
be allowed outside of JSTL (1.0) tags. The fn:length() function I
originally mentioned is part of JSTL 1.1 anyway so it sounds like you
just need to make sure everything is configured for the current specs
and you should be good. Hope that will fix it up for you.

 -Christian

Murray Steele wrote:

 Perhaps this page might provide the solution?

 http://www.oreillynet.com/cs/user/view/cs_msg/32931

 Wrong taglib uri's or wrong webapp specification in your web.xml.

 Muz

 On 2 Aug 2005, at 14:32, Marius Botha wrote:

  You know your stuff hey :)
 
  I believe I do use Tomcat 5 (running inside JBoss 3.2) and as a result 
  have
  their JSTL (looks like 1.1) and JSP-2.0.jar. Where do I find or can I 
  check
  if I have the TLD for the functions library (so I can include it if
  missing)? At the moment I am including the TLD's in my WAR project and
  specify them in the web.xml file.
 
  Thanks again.
 
  Marius
 
  -Original Message-
  From: Murray Steele [mailto:[EMAIL PROTECTED]
  Sent: 02 August 2005 02:31
  To: Tag Libraries Users List
  Subject: Re: How to print an int with a c:out tag?
 
 
  I suspect that you are using either Tomcat 4.1.x and / or Standard 1.0x
  for your JSTL.  EL functions are part of the JSTL 1.1 spec (JSP 2.0)
  and aren't supported on Tomcat 4.1.x or Standard 1.0x (JSP 1.2 and JSTL
  1.0 respectively).  If you want to use the fn:length you need to use
  JSTL 1.1 and hence Standard 1.1 and / or Tomcat 5.x.  (I think those
  versions are correct, someone correct me if I'm wrong).
 
  If you cant change the version of Tomcat / JSTL you use:
  1. You could alter your myController.getOpenActivitiesForResource
  method to return a class that extends list to provide a getSize() (and
  hence your original c:out value=${myList.size}/ would work.
  2. Find some other Tag lib that lets you output list sizes.
  (unstandard from the sandbox does this)
  3. Just use a scriptlet %= ((MyControllerClass)
  pageContext.findAttribute(myController)).getOpenActivitiesForResource
  (
  ).size() %.
 
  Muz
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 --
 Murray Steele
 Senior Developer

 Peoples Archive
 w: http://www.peoplesarchive.com
 t: 0207 323 0323
 d: 0207 631 9147

 This email has been scanned by Postini.
 For more information please visit http://www.postini.com


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: c:import problem

2004-10-21 Thread Christian Taylor
Hi Kris,

Thanks for the reply. I have managed to get it worked out, but only be
looking even closer at the Tomcat source. It turns out to be the way
Tomcat wraps a request when using a RequestDispatcher. If the request
given to the dispatcher is a wrapper, Tomcat will look up the chain
until it finds the real original non-wrapped request, and wrap that.
That was a bit different than the behaviour I expected (I assumed it
would wrap my own wrapper, not look for the original request). I
modified my own wrapper's getParameter() method to call
super.getParameter() and now it works.

This behavour isn't specified in the servlet spec or the Tomcat docs...
Maybe it should be (would've saved me 5 hours of debugging). But I'll
bring that up on an appropriate list and not here. Thanks again for
replying.

Christian

-Original Message-
From: Kris Schneider [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 20, 2004 4:03 PM
To: Tag Libraries Users List
Subject: Re: c:import problem

Christian,

Not sure if you're still wrestling with this, but I just wanted to post
to say that I've been meaning to slap a little test app together as a
sanity check and I'll post back when I get the chance to code  run
it...

Quoting Christian Taylor [EMAIL PROTECTED]:

 Hi,
 
 I'm new to this list, but far from a newbie when it comes to servlets,

 JSP, JSTL and Tomcat. I've spent hours trying to debug this problem, 
 searched the net and mailing lists and haven't been able to find a 
 solution. Here is my situation:
 
 My application has many pages that use c:import to include a common 
 header. The header takes a title parameter. I've seen other people 
 doing this in the archives of this list. My code looks like this:
 
 c:import url=/include/header.jsp
   c:param name=title value=Title of the page/ /c:import
 
 header.jsp uses the title for the title tag as well as to display to

 the user at the top of the page.
 
 These pages can be accessed in two different ways:
 
 1) By a normal user of the application through a web browser
 2) From a servlet that uses RequestDispatchers to capture some pages
to save as files that can be viewed offline.
 
 The problem I'm having is with #2. The title parameter does NOT get 
 passed to header.jsp, and neither do request-scoped variables.
 
 My offline servlet creates request and response wrappers to pass to 
 the RequestDispatcher's include() method. The wrapped request 
 overrides the relevent parameter methods (getParameter(), 
 getParameterMap(),
 etc.) and provides setter methods so I can pass parameters to the 
 pages to be captured. It also defines a request-scoped variable 
 called _OfflineBackup which the pages can use to detect how they are 
 being accessed (some paths, etc. need to be different if the page is 
 to work offline).
 
 My response wrapper is a typical override getOutputStream() and
 getWriter() to capture the output type of thing.
 
 I've looked through the Tomcat and taglibs-standard sources and can't 
 find anything that would help. The code for the c:import tag appears

 to build a query string from the c:param tags and pass it as part of

 the URL to the RequestDispatcher it creates, but Tomcat's 
 ApplicationDispatcher implementation doesn't seem to do anything with 
 it, from what I can see in the source (but I'm not a Tomcat developer 
 and am not that familiar with the source). The parameters in the 
 wrapped request can be accessed from header.jsp, but not the actual 
 parameters passed to header.jsp using c:param.
 
 This all leads me to my real question... why does my 'title' parameter

 work fine when I simply view the pages normally in a browser, but not 
 when I use a RequestDispatcher and my wrapped request/response? The 
 problem appears to be that Tomcat doesn't look at the parameters in 
 the path when getRequestDispatcher(path) is called, which makes me 
 wonder why the c:param tag ever works at all (but as I said, I'm not

 a Tomcat developer and have limited knowledge of the source so I could

 be wrong here, this is just what I've found from digging through the 
 sources). My wrappers seem to be working fine, and the import works 
 properly when viewing the page in a browser.
 
 I hope I explained everything well enough and I apologize for this 
 being a bit long. I'm using Tomcat 5.0.28 and taglibs-standard 1.1.1. 
 This is a servlet 2.4/jsp 2.0 application. Thanks in advance to anyone

 who might be able to help me here!
 
 Christian

--
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



c:import problem

2004-10-19 Thread Christian Taylor
Hi,
I'm new to this list, but far from a newbie when it comes to servlets, 
JSP, JSTL and Tomcat. I've spent hours trying to debug this problem, 
searched the net and mailing lists and haven't been able to find a 
solution. Here is my situation:

My application has many pages that use c:import to include a common 
header. The header takes a title parameter. I've seen other people 
doing this in the archives of this list. My code looks like this:

c:import url=/include/header.jsp
 c:param name=title value=Title of the page/
/c:import
header.jsp uses the title for the title tag as well as to display to 
the user at the top of the page.

These pages can be accessed in two different ways:
1) By a normal user of the application through a web browser
2) From a servlet that uses RequestDispatchers to capture some pages
  to save as files that can be viewed offline.
The problem I'm having is with #2. The title parameter does NOT get 
passed to header.jsp, and neither do request-scoped variables.

My offline servlet creates request and response wrappers to pass to 
the RequestDispatcher's include() method. The wrapped request overrides 
the relevent parameter methods (getParameter(), getParameterMap(), 
etc.) and provides setter methods so I can pass parameters to the pages 
to be captured. It also defines a request-scoped variable called 
_OfflineBackup which the pages can use to detect how they are being 
accessed (some paths, etc. need to be different if the page is to work 
offline).

My response wrapper is a typical override getOutputStream() and 
getWriter() to capture the output type of thing.

I've looked through the Tomcat and taglibs-standard sources and can't 
find anything that would help. The code for the c:import tag appears 
to build a query string from the c:param tags and pass it as part of 
the URL to the RequestDispatcher it creates, but Tomcat's 
ApplicationDispatcher implementation doesn't seem to do anything with 
it, from what I can see in the source (but I'm not a Tomcat developer 
and am not that familiar with the source). The parameters in the wrapped 
request can be accessed from header.jsp, but not the actual parameters 
passed to header.jsp using c:param.

This all leads me to my real question... why does my 'title' parameter 
work fine when I simply view the pages normally in a browser, but not 
when I use a RequestDispatcher and my wrapped request/response? The 
problem appears to be that Tomcat doesn't look at the parameters in the 
path when getRequestDispatcher(path) is called, which makes me wonder 
why the c:param tag ever works at all (but as I said, I'm not a Tomcat 
developer and have limited knowledge of the source so I could be wrong 
here, this is just what I've found from digging through the sources). My 
wrappers seem to be working fine, and the import works properly when 
viewing the page in a browser.

I hope I explained everything well enough and I apologize for this being 
a bit long. I'm using Tomcat 5.0.28 and taglibs-standard 1.1.1. This is 
a servlet 2.4/jsp 2.0 application. Thanks in advance to anyone who might 
be able to help me here!

Christian