How to use request.getParamentValues(String)

Hi All

I have problem using request.getParamentValues(String) method in my appliction.

Example:I have a selection box in hospital.jsp file,i want to pass multiple value selected in hospital.jsp file to Results_hospital.jsp file.for that iam using

String[] job=request.getPartmeterValues(String);.

The problem is if i sent morethen three value it is working fine but if i pass below three value it is giving error saying that:

Internal Servlet Error:

javax.servlet.ServletException

at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)

at login.Results_OffHosJobStatus_10._jspService(Results_OffHosJobStatus_10.java:367)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)

at javax.servlet.http.HttpServlet.service(HttpServlet.java)

at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)

at org.apache.tomcat.core.Handler.service(Handler.java:223)

at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)

at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:788)

at org.apache.tomcat.core.ContextManager.service(ContextManager.java:701)

at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:143)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:424)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:497)

at java.lang.Thread.run(Thread.java:484)

Root cause:

java.lang.ArrayIndexOutOfBoundsException

at login.Results_OffHosJobStatus_10._jspService(Results_OffHosJobStatus_10.java:125)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)

at javax.servlet.http.HttpServlet.service(HttpServlet.java)

at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)

at org.apache.tomcat.core.Handler.service(Handler.java:223)

at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)

at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:788)

at org.apache.tomcat.core.ContextManager.service(ContextManager.java:701)

at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:143)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:424)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:497)

at java.lang.Thread.run(Thread.java:484)

.

Help me

Thanks

venkat

[2674 byte] By [venkatpathipati] at [2007-9-26 1:22:45]
# 1
send the piece of code that calls the method and works if it. We'll see where the problem is
seralex at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
You should paste more code here.
fayefun at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Are you using GET or POST? Try using POST.Also, if you're iterating over the paremeters with something likefor (int j=0; j<=job.length; j++) you'll have to replace <= with =
leukbr at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hi

This is the code:

file name:Hospital.htm

<HTML>

<HEAD></HEAD>

<Body>

<form name=f1 action="./Results_Hospital.jsp" method=post>

<TABLE width="700"><tr><td bgcolor="#505c90"><FONT color=white face=Verdana size=2><STRONG>Select job status.</STRONG></FONT></TABLE>

<TABLE align="left" width="70%" border=0>

<TR>

<TD align=left width="28%"><div align="right"><FONT face=Verdana size=2>Job status type</font></div></td>

<TD width="72%"><SELECT multiple name=selJobStatus><OPTION value="">Select job status type</OPTION>

<OPTION value="n">New jobs</OPTION>

<OPTION value="a">Assigned jobs</OPTION>

<OPTION value="l">Locked jobs</OPTION>

<OPTION value="s">Saved but incompleted jobs</OPTION>

<OPTION value="x">Saved and exited jobs</OPTION>

<OPTION value="e">Edited jobs</OPTION>

<OPTION value="c">Completed jobs</OPTION>

<OPTION value="d">Delivered jobs</OPTION>

<OPTION value="r">Rejected jobs</OPTION>

</SELECT><FONT face=Verdana size=1 color=red>*</FONT></TD>

</TR>

</TABLE>

</form>

</body>

<html>

filename:Result_hospital.jsp

<HTML>

<HEAD>

<TITLE>Hospital's job status report</TITLE>

<META http-equiv="Pragma" content="no-cache">

</HEAD>

<body bgcolor="#eff5f9" alink=black vlink=black link=black>

<FORM name="Results" method=post>

<%@page import="java.sql.*,java.util.Date,java.lang.*"%>

<%!String JobStatus;

String[] pp;

%>

<%

pp=request.getParameterValue("selJobStatus");

%>

</form>

</body>

</html>

Just pass more then three elements and findout the array length.Also pass lessthen three elements and findout the array length.

Thanks

venkat

venkatpathipati at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hi leukbr

Iam using post method.How can iterate without knowing the length of the array.This is the code iam using just go through this code if sugesstion mail me venky_00@rediffmail.com

file name:Hospital.htm

<HTML>

<HEAD></HEAD>

<Body>

<form name=f1 action="./Results_Hospital.jsp" method=post>

<TABLE width="700"><tr><td bgcolor="#505c90"><FONT color=white face=Verdana size=2><STRONG>Select job status.</STRONG></FONT></TABLE>

<TABLE align="left" width="70%" border=0>

<TR>

<TD align=left width="28%"><div align="right"><FONT face=Verdana size=2>Job status type</font></div></td>

<TD width="72%"><SELECT multiple name=selJobStatus><OPTION value="">Select job status type</OPTION>

<OPTION value="n">New jobs</OPTION>

<OPTION value="a">Assigned jobs</OPTION>

<OPTION value="l">Locked jobs</OPTION>

<OPTION value="s">Saved but incompleted jobs</OPTION>

<OPTION value="x">Saved and exited jobs</OPTION>

<OPTION value="e">Edited jobs</OPTION>

<OPTION value="c">Completed jobs</OPTION>

<OPTION value="d">Delivered jobs</OPTION>

<OPTION value="r">Rejected jobs</OPTION>

</SELECT><FONT face=Verdana size=1 color=red>*</FONT></TD>

</TR>

</TABLE>

</form>

</body>

<html>

filename:Result_hospital.jsp

<HTML>

<HEAD>

<TITLE>Hospital's job status report</TITLE>

<META http-equiv="Pragma" content="no-cache">

</HEAD>

<body bgcolor="#eff5f9" alink=black vlink=black link=black>

<FORM name="Results" method=post>

<%@page import="java.sql.*,java.util.Date,java.lang.*"%>

<%!String JobStatus;

String[] pp;

%>

<%

pp=request.getParameterValue("selJobStatus");

out.println("Length of array is :"+pp.length);

%>

</form>

</body>

</html>

Just pass more then three elements and findout the array length.Also pass lessthen three elements and findout the array length.

Thanks

venkat

venkatpathipati at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi,It is pp=request.getParameterValues("selJobStatus");not pp=request.getParameterValue("selJobStatus");It is working fine with mepsvinayram@yahoo.com
psvinayram at 2007-6-29 1:00:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...