hima bindu wrote:
>
> hi!
>
> i have got a real problem with my applet not
> recognizing the parameters my jsp page has passed to
> the applet.
> code for the jsp:
>
> <%
> String pname[]={names for the parameters};
> String rec[]={values from the database };
> %>
> <jsp:plugin type="applet" ......>
> <jsp:params>
> <% for(int i=0;i<10;i++)
>
> {
> %>
> <param name='<%= pname[i]%>' value='<%=rec[i]%>'>
> <%
> }
> %>
> </jsp:params>
> </jsp:plugin>
>
> my jsp code is compiling well.
> but when i use getParameter() inside my JApplet
> it is returning a null value.
The reason is that you're generating the "param" tags using a scriptlet.
This doesn't work because they need to be seen by the JSP container when
it translates the JSP page into a servlet. Besides, the element you should
use within the <jsp:params> element is <jsp:param>, not <param>.
You need to do something like this instead:
<jsp:plugin type="applet" ......>
<jsp:params>
<jsp:param name="<%= pname[0] %>" value="<%= rec[0] %>" />
<jsp:param name="<%= pname[1] %>" value="<%= rec[1] %>" />
...
<jsp:param name="<%= pname[9] %>" value="<%= rec[9] %>" />
</jsp:params>
</jsp:plugin>
This assumes that there's always 10 elements in the array and that
each element has a non-null value. Otherwise you have to check for
null values in the expression as well, e.g.
<%= (pname[0] == null ? "" : pname[0]) %>
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets