Sample code error - method getParameters

C

cliveswan

Hi,

I get an method getParameters error when running the sample code.
I looked for a org.javax.jar to import, could not find it??

Could anyone help to point out what is wrong.

Thanks

Clive

Error(38,1): method getParameters(java.lang.String) not found in
interface javax.servlet.http.HttpServletRequest


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page
import = "java.lang.*"
import = "javax.servlet.*"
import = "java.lang.*"
%>
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested"
prefix="nested"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-
template"prefix="template"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
prefix="tiles"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252"/>
<title>Home</title>
<style type="text/css">
body {
background-color: #ffa5ff;
}
a:link { color: #0000ff; }
</style>
</head>
<body>

<select name="menuName" size="1">
<option value="Value0" selected>Yes</option>
<option value="Value1">No</option>
</select>

<%
String sn1;
String sn2;

sn1 = request.getParameters("Value0");
sn2 = request.getParameters("Value1");

// n1 = Integer.ParseInt(sn1);

out.println("Value is" sn1 + sn2);
%>

</body>
</html>
 
S

stefanomnn

hi, correct method is getParameter, without final "s".

if you have multi values for a parameter (such us in checkbox), you
can use

String[] getParameterValues(String paramName)

Stefano
 
C

cliveswan

Hi Stefano,

Thanks for pointing out the typo, really silly & annoying.

I corrected the typo still getting error (line 34, ; required??)

I understand sn1 = getParameter("Value0");

I do not understand the: String[] getParameterValues(String paramName)
How do you assign this??

Thanks for your assistance.

clive
 
S

stefanomnn

Hi,
suppose you have this in your form:
<input type="ceckbox" name="selectedColors" value="red"/>Red
<input type="ceckbox" name="selectedColors" value="yellow"/>Yellow
<input type="ceckbox" name="selectedColors" value="green"/>Green

in your jsp,

String[] colors= request.getParameterValues("selectedColors");
// colors have just colors user selected

Stefano :)
 
C

cliveswan

Hi Stefano,

Noticed that I left out the System before out.println

I have amended the code, but am still getting an error >>> ; expected

I have pasted the revised code below.
PS thanks for your patience.

//>>>>>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page
import="java.lang.*"
import="javax.servlet.*"
import="java.lang.*"
%>
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252"/>
<title>Home</title>
<style type="text/css">
body {
background-color: #ffa5ff;
}
a:link { color: #0000ff; }
</style>
</head>
<body>

<select name="roofTopdrop" size="1">
<option value="Roof0" SELECTED>Yes</option>
<option value="Roof1">N0</option>
<option value="Roof2">-</option>
</select>


// n1 = Integer.ParseInt(roofTopdrop);
<%
String[] roofTop = request.getParameterValues("roofTopdrop");
System.out.println("Value is" roofTop);
%>

</body>
</html>
 
C

cliveswan

Hi Stefano,

Error, the System.out.println was within the <% %>, did not seem to
like that.

The JSP is creating website with drop-down listbox.
It prints out the System.out.println("Value is" roofTop);
Rather than the option selected in drop-down????

Thanks

Clive
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top