You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Cheung <pe...@home.com> on 2000/06/30 06:50:58 UTC

options tag

    I noticed that subscription.jsp in the example uses a "options" tag (see
the code below):

      <struts:select property="type">
        <struts:options name="serverTypeValues"
                   labelName="serverTypeLabels"/>
      </struts:select>

    After I read thru the tag.html, I am still not understand of how to
provide the collection of the label and value to this tag, esp. I cannot
locate the piece of code that creates the "serverTypeValues" or the
"serverTypeLabels" objects. I wonder if anyone explain to me how those 2
objects are being created. Thx in advance.


Re: A suggestion on internationalization

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Robert Edgar wrote:

> It would be really nice to build in an option to use an algorythm something
> like Jason Hunters LocaleNegotiator for determining the Locale rather than a
> session attribute ie driven by the accept-languages header.
>
> I know some sites dont do it this way and use cookies or session attributes
> instead but some (a few :-(( ) of us do and (IMHO) this is the correct way
> to do it, and it would be nice to have the option especially as someone has
> already written the code :-) .
>

Thanks for the suggestions -- I will look at this in more detail.

>
> Maybe driven by a param in web.xml, also needs a param to allow it to ignore
> the charset map and use utf-8 (for those of us who want to use utf-8 instead
> of things like BIG5 or GB2312 ).
>

Internationalization is also an issue being discussed for the next version of
the servlet and JSP specifications.  We may end up seeing the servlet container
doing more of this kind of work so that apps don't have to, but it is not yet
clear what the final form will be.

>
> In the mean time I believe I can subclass the action servlet and pre process
> the request and set the session attribute on each call?
>

Yes.  The simplest thing would probably be overriding the
processActionInstance() method to set the session Locale right before the action
method is accessed -- something like this:

    protected void processActionInstance(...) ... {

        HttpSession session = request.getSession();
        ... calculate and store the correct locale ...
        super.processActionInstance(...);

    }

>
> Thanks
> Rob

Craig



A suggestion on internationalization

Posted by Robert Edgar <ro...@hkstar.com>.
It would be really nice to build in an option to use an algorythm something
like Jason Hunters LocaleNegotiator for determining the Locale rather than a
session attribute ie driven by the accept-languages header.

I know some sites dont do it this way and use cookies or session attributes
instead but some (a few :-(( ) of us do and (IMHO) this is the correct way
to do it, and it would be nice to have the option especially as someone has
already written the code :-) .

Maybe driven by a param in web.xml, also needs a param to allow it to ignore
the charset map and use utf-8 (for those of us who want to use utf-8 instead
of things like BIG5 or GB2312 ).

In the mean time I believe I can subclass the action servlet and pre process
the request and set the session attribute on each call?


Thanks
Rob


RE: Sorry, Yet another problem

Posted by Robert Edgar <ro...@hkstar.com>.
Thanks for the very quick response<g>

I now have got my first "struts" page working so I am happy.

Will use the "compile" script for today but will take a look at ant when I
have time..........

Just rushing to get a site up by next weekend, converting all the code to
use struts, not as bad as it sounds as I had designed it with the idea that
it could "plug" into different strategies. Mainly involves creating
"actions" to call existing bus obj and doing the front ends with taglibs
which I needed to do anyway...


Rob

-----Original Message-----
From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
Sent: Sunday, July 02, 2000 1:36 PM
To: struts-user@jakarta.apache.org
Subject: Re: Sorry, Yet another problem


Robert Edgar wrote:

> Well sort of resolved it, thanks to another thread with a similar
problem...
>
> I had placed another copy of struts jar under jdk1.3/jre/lib/ext as I need
> it there to compile stuff, BUT with that copy there then I get the erro
> message if I run Tomcat. Delete this jar and its OK.
>
> It a pain but now I must copy struts to the directory, compile, delete
> struts, restart tomcat etc etc etc....
>
> This is a real pain...
>
> any thoughts on another work around
>

Two different approaches come to mind.

* Create a "compile" script for your application that temporarily adds
  the struts.jar file to the compiler's class path.  On Unix, you'd be
  doing something like this:

    javac -classpath /path/to/struts.jar:$CLASSPATH "$@"

  On Windows, the equivalent is:

    javac -classpath \path\to\struts.jar;%CLASSPATH% %1 %2 %3 %4 %5 %6 %7 %8
%9

* Use the "Ant" build tool <http://jakarta.apache.org/ant> that is used
  to build all of the Jakarta projects.  Ant is a portable replacement
  for Make that runs on any platform, and (among other things) lets
  you configure the class path used by compilations.

I use the latter approach for building the Struts distribution itself -- you
can look
at the "build.xml" file in the "etc" directory of the Struts distribution to
get a feel
for the power of Ant.  Ant is being adopted by many of the open source
Java-based
projects as their standard build environment.

>
> Rob
>

Craig


>
> -----Original Message-----
> From: Robert Edgar [mailto:robedgar@hkstar.com]
> Sent: Sunday, July 02, 2000 10:45 AM
> To: struts-user@jakarta.apache.org
> Subject: Sorry, Yet another problem
>
> Sorry to be a pain,
> I have another error, sure its my fault,hopefully once I have my first
page
> up the rest will be smooth sailing <g>
>
> I think this is related to finding the .properties file, I simply copied
the
> resoureces.propeties file and the tag in web.xml form thje example and
> changed the org.a.....struts.example to com.mamba.common. which is hwere
my
> stuff is.
>
> The only diff I can see is that allthe files ar ein one directory in the
> example but I have split some things into a directory called common and
most
> of the action/form stuff into another directory called jbo (mainly for
> historic reason as this is a conversion of an existing of application to
use
> struts).
>
> Thanks for the help and patience
>
> Rob
>
> javax.servlet.jsp.JspException: Missing resources attribute
> org.apache.struts.action.MESSAGE
>         at
org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:332)
>         at
>
_0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
> java:68)
>         at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:174)
>         at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
>         at
org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
>         at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java:160)
>         at
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
> )
>         at java.lang.Thread.run(Thread.java:484)



Re: Sorry, Yet another problem

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Robert Edgar wrote:

> Well sort of resolved it, thanks to another thread with a similar problem...
>
> I had placed another copy of struts jar under jdk1.3/jre/lib/ext as I need
> it there to compile stuff, BUT with that copy there then I get the erro
> message if I run Tomcat. Delete this jar and its OK.
>
> It a pain but now I must copy struts to the directory, compile, delete
> struts, restart tomcat etc etc etc....
>
> This is a real pain...
>
> any thoughts on another work around
>

Two different approaches come to mind.

* Create a "compile" script for your application that temporarily adds
  the struts.jar file to the compiler's class path.  On Unix, you'd be
  doing something like this:

    javac -classpath /path/to/struts.jar:$CLASSPATH "$@"

  On Windows, the equivalent is:

    javac -classpath \path\to\struts.jar;%CLASSPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9

* Use the "Ant" build tool <http://jakarta.apache.org/ant> that is used
  to build all of the Jakarta projects.  Ant is a portable replacement
  for Make that runs on any platform, and (among other things) lets
  you configure the class path used by compilations.

I use the latter approach for building the Struts distribution itself -- you can look
at the "build.xml" file in the "etc" directory of the Struts distribution to get a feel
for the power of Ant.  Ant is being adopted by many of the open source Java-based
projects as their standard build environment.

>
> Rob
>

Craig


>
> -----Original Message-----
> From: Robert Edgar [mailto:robedgar@hkstar.com]
> Sent: Sunday, July 02, 2000 10:45 AM
> To: struts-user@jakarta.apache.org
> Subject: Sorry, Yet another problem
>
> Sorry to be a pain,
> I have another error, sure its my fault,hopefully once I have my first page
> up the rest will be smooth sailing <g>
>
> I think this is related to finding the .properties file, I simply copied the
> resoureces.propeties file and the tag in web.xml form thje example and
> changed the org.a.....struts.example to com.mamba.common. which is hwere my
> stuff is.
>
> The only diff I can see is that allthe files ar ein one directory in the
> example but I have split some things into a directory called common and most
> of the action/form stuff into another directory called jbo (mainly for
> historic reason as this is a conversion of an existing of application to use
> struts).
>
> Thanks for the help and patience
>
> Rob
>
> javax.servlet.jsp.JspException: Missing resources attribute
> org.apache.struts.action.MESSAGE
>         at org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:332)
>         at
> _0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
> java:68)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:174)
>         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
>         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java:160)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
> )
>         at java.lang.Thread.run(Thread.java:484)


RE: Sorry, Yet another problem

Posted by Robert Edgar <ro...@hkstar.com>.
Well sort of resolved it, thanks to another thread with a similar problem...

I had placed another copy of struts jar under jdk1.3/jre/lib/ext as I need
it there to compile stuff, BUT with that copy there then I get the erro
message if I run Tomcat. Delete this jar and its OK.

It a pain but now I must copy struts to the directory, compile, delete
struts, restart tomcat etc etc etc....


This is a real pain...

any thoughts on another work around

Rob

-----Original Message-----
From: Robert Edgar [mailto:robedgar@hkstar.com]
Sent: Sunday, July 02, 2000 10:45 AM
To: struts-user@jakarta.apache.org
Subject: Sorry, Yet another problem


Sorry to be a pain,
I have another error, sure its my fault,hopefully once I have my first page
up the rest will be smooth sailing <g>

I think this is related to finding the .properties file, I simply copied the
resoureces.propeties file and the tag in web.xml form thje example and
changed the org.a.....struts.example to com.mamba.common. which is hwere my
stuff is.

The only diff I can see is that allthe files ar ein one directory in the
example but I have split some things into a directory called common and most
of the action/form stuff into another directory called jbo (mainly for
historic reason as this is a conversion of an existing of application to use
struts).

Thanks for the help and patience

Rob

javax.servlet.jsp.JspException: Missing resources attribute
org.apache.struts.action.MESSAGE
	at org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:332)
	at
_0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
java:68)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)



Sorry, Yet another problem

Posted by Robert Edgar <ro...@hkstar.com>.
Sorry to be a pain,
I have another error, sure its my fault,hopefully once I have my first page
up the rest will be smooth sailing <g>

I think this is related to finding the .properties file, I simply copied the
resoureces.propeties file and the tag in web.xml form thje example and
changed the org.a.....struts.example to com.mamba.common. which is hwere my
stuff is.

The only diff I can see is that allthe files ar ein one directory in the
example but I have split some things into a directory called common and most
of the action/form stuff into another directory called jbo (mainly for
historic reason as this is a conversion of an existing of application to use
struts).

Thanks for the help and patience

Rob

javax.servlet.jsp.JspException: Missing resources attribute
org.apache.struts.action.MESSAGE
	at org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:332)
	at
_0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
java:68)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)


Re: Error in struts tld

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Robert Edgar wrote:

> Thanks,
> I have multiple Servlet and Mapping sections in web.xml and I hadnt realise
> you cannot mix them up. You must have ALL servlets first then ALL mappings
>
> Doesnt seem to effect the working of the app, just blows up on taglibs
>

That is true for Tomcat 3.1, which does not validate web.xml as it parses it.

In Tomcat 3.2, that will no longer be the case -- web.xml will be validated when
Tomcat starts up so you won't get surprised like this the first time you use a
tag library.

>
> Rob
>

Craig



RE: Error in struts tld

Posted by Robert Edgar <ro...@hkstar.com>.
Thanks,
I have multiple Servlet and Mapping sections in web.xml and I hadnt realise
you cannot mix them up. You must have ALL servlets first then ALL mappings

Doesnt seem to effect the working of the app, just blows up on taglibs

Rob



-----Original Message-----
From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
Sent: Sunday, July 02, 2000 3:15 AM
To: struts-user@jakarta.apache.org
Subject: Re: Error in struts tld


Robert Edgar wrote:

> Got the following error
> Any thoughts on what the problem might be
> Rob
>
> org.apache.jasper.JasperException: Unable to open taglibrary
> /WEB-INF/struts.tld : Parse Error in the tag library descriptor: Element
> "web-app" does not allow "servlet" here.
>         at
>

It's a little obscure, but the parsing problem isn't in struts.tld -- it is
in the
web.xml file for your application.  Let me explain ...

Tomcat 3.1 currently does not validate the web.xml file against the
corresponding DTD
when it initializes your application.  However, Jasper (the JSP page
compiler) does do
so, when it tries to read the web.xml to find the <taglib> declarations.
The error
means that you've got a <servlet> entry in web.xml after some other entry
that is
supposed to follow it.

You can see the DTD for the web.xml file by opening the file
"$TOMCAT_HOME/conf/web.dtd".  In particular, the definition of the <web-app>
element
defines the order in which the sub-elements must be listed.

Craig McClanahan



Re: Error in struts tld

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Robert Edgar wrote:

> Got the following error
> Any thoughts on what the problem might be
> Rob
>
> org.apache.jasper.JasperException: Unable to open taglibrary
> /WEB-INF/struts.tld : Parse Error in the tag library descriptor: Element
> "web-app" does not allow "servlet" here.
>         at
>

It's a little obscure, but the parsing problem isn't in struts.tld -- it is in the
web.xml file for your application.  Let me explain ...

Tomcat 3.1 currently does not validate the web.xml file against the corresponding DTD
when it initializes your application.  However, Jasper (the JSP page compiler) does do
so, when it tries to read the web.xml to find the <taglib> declarations.  The error
means that you've got a <servlet> entry in web.xml after some other entry that is
supposed to follow it.

You can see the DTD for the web.xml file by opening the file
"$TOMCAT_HOME/conf/web.dtd".  In particular, the definition of the <web-app> element
defines the order in which the sub-elements must be listed.

Craig McClanahan



Error in struts tld

Posted by Robert Edgar <ro...@hkstar.com>.
Got the following error
Any thoughts on what the problem might be
Rob

org.apache.jasper.JasperException: Unable to open taglibrary
/WEB-INF/struts.tld : Parse Error in the tag library descriptor: Element
"web-app" does not allow "servlet" here.
	at
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
ntListener.java:672)
	at
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList
ener.java:116)
	at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:1073)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
	at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
rvlet.java:149)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:161)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)


RE: options tag

Posted by Robert Edgar <ro...@hkstar.com>.
Just a thought but would it make sense to use a hashtable for this rather
than two arrays?

Rob

-----Original Message-----
From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
Sent: Friday, June 30, 2000 1:27 PM
To: struts-user@jakarta.apache.org
Subject: Re: options tag


Peter Cheung wrote:

>     I noticed that subscription.jsp in the example uses a "options" tag
(see
> the code below):
>
>       <struts:select property="type">
>         <struts:options name="serverTypeValues"
>                    labelName="serverTypeLabels"/>
>       </struts:select>
>
>     After I read thru the tag.html, I am still not understand of how to
> provide the collection of the label and value to this tag, esp. I cannot
> locate the piece of code that creates the "serverTypeValues" or the
> "serverTypeLabels" objects. I wonder if anyone explain to me how those 2
> objects are being created. Thx in advance.

In the particular case of the example, they are being created (as string
arrays)
in the scriptlet at the top of the page:

    <%
        pageContext.setAttribute("serverTypeValues",
            new String[] { "imap", "pop3" });
        pageContext.setAttribute("serverTypeLabels",
            new String[] { "IMAP Protocol", "POP3 Protocol" });
    %>

Decomposing this a little, we see that the setAttribute() method takes two
parameters -- a name by which this object will be accessible, and an Object
which, in this case, is a String array.  The stuff in curly brackets is the
initialization of the (unnamed) arrays, which each end up with two elements.

In a real application, I expect that you would normally be pre-initializing
the
values and corresponding labels objects in the application's startup code,
probably storing them as servlet context attributes.  Alternatively, they
could
have been computed in an Action class and stored as request attributes prior
to
forwarding to this page (this might be needed so that you can get the
correct
translations).  The important things to remember:

* The number of entries in the "labels" list has to match the
  number of entries in the "values" list.

* If you do not specify "labelName" or "labelProperty", the
  values list is used for both the value returned to the server
  and the value displayed to the user.

* There is no "scope" attribute on the <struts:options> tag,
  because the tag internally uses PageContext.findAttribute
  to search through all the scopes (page, request, session,
  and application) until it finds a bean with the name you
  specify.

Hope this helps.

Craig



Struts Error

Posted by Robert Edgar <ro...@hkstar.com>.
Getting the following error (Tomcat31, NT4, J1.3)

Error: 500
Location: /struts-example/logon.jsp
Internal Servlet Error:

javax.servlet.ServletException: Can't find a method to write property
'maxlength' in a bean of type 'org.apache.struts.taglib.TextTag'
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:386)
	at
_0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
java:339)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)

Root cause:
org.apache.jasper.JasperException: Can't find a method to write property
'maxlength' in a bean of type 'org.apache.struts.taglib.TextTag'
	at
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibra
ry.java:215)
	at
_0002flogon_0002ejsplogon_jsp_0._jspService(_0002flogon_0002ejsplogon_jsp_0.
java:159)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)


Any ideas on the problem
Rob


Re: options tag

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Peter Cheung wrote:

>     I noticed that subscription.jsp in the example uses a "options" tag (see
> the code below):
>
>       <struts:select property="type">
>         <struts:options name="serverTypeValues"
>                    labelName="serverTypeLabels"/>
>       </struts:select>
>
>     After I read thru the tag.html, I am still not understand of how to
> provide the collection of the label and value to this tag, esp. I cannot
> locate the piece of code that creates the "serverTypeValues" or the
> "serverTypeLabels" objects. I wonder if anyone explain to me how those 2
> objects are being created. Thx in advance.

In the particular case of the example, they are being created (as string arrays)
in the scriptlet at the top of the page:

    <%
        pageContext.setAttribute("serverTypeValues",
            new String[] { "imap", "pop3" });
        pageContext.setAttribute("serverTypeLabels",
            new String[] { "IMAP Protocol", "POP3 Protocol" });
    %>

Decomposing this a little, we see that the setAttribute() method takes two
parameters -- a name by which this object will be accessible, and an Object
which, in this case, is a String array.  The stuff in curly brackets is the
initialization of the (unnamed) arrays, which each end up with two elements.

In a real application, I expect that you would normally be pre-initializing the
values and corresponding labels objects in the application's startup code,
probably storing them as servlet context attributes.  Alternatively, they could
have been computed in an Action class and stored as request attributes prior to
forwarding to this page (this might be needed so that you can get the correct
translations).  The important things to remember:

* The number of entries in the "labels" list has to match the
  number of entries in the "values" list.

* If you do not specify "labelName" or "labelProperty", the
  values list is used for both the value returned to the server
  and the value displayed to the user.

* There is no "scope" attribute on the <struts:options> tag,
  because the tag internally uses PageContext.findAttribute
  to search through all the scopes (page, request, session,
  and application) until it finds a bean with the name you
  specify.

Hope this helps.

Craig