• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot get parameters from request object

 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am looking to find away to obtain the parameter names from a request object. From looking at the API i have found two ways to get this. the first
<html>
<head>
</head>
<body>
<%
java.util.Enumeration enum = request.getParameterNames() ;
if( enum.hasMoreElements() ){
%>
<%= enum.nextElement() %>
<%
}
%>
</body>
</html>
only seems to find the last parameter name in the URL. The other using
Map myMap = request.getParameterMap() ;
falls over as tomcat says that it cannot find the method. throwing a
Method getParameterMap() not found in interface javax.servlet.http.HttpServletRequest.
Map myMap = request.getParameterMap() ;
i have checked the classpath and the correct version of the jar file is there. i can compile the page ok in my IDE with that jar.
does anybody have any ideas what is going on or can offer a different way to get the parameter names
thanks for any help in advance
cheers
david
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are the parameters being passed as a GET? what does the URL look like with the Parameters on the end?
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jessica,
yes when i try a 'get' it comes out as
http://localhost:8080/bluesky/activity/formReturn.jsp?dealerName=me&dealerAddress1=house+&dealerAddress2=street&extraInformation=order&Submit=Submit
but the only attribute coming out is extraInformation. i am going to upgrade my tomcat just now to make sure this is not a known bug.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you change your 'if to a 'while'?
if( enum.hasMoreElements() ){

getParameterMap()?? Never heard of it. May be it's new with the current version of the Servlet/JSP API.
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers,
thought i had been doing this programming for a while.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun Bello:
Can you change your 'if to a 'while'?
if( enum.hasMoreElements() ){

nice catch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!