• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getParameter

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
com.ibm.servlet.engine.webapp.WebAppDispatcherRequest myReq =(com.ibm.servlet.engine.webapp.WebAppDispatcherRequest) request;
String url = "/Remote";
myReq.setRawParameters(temp_map);
myReq.setPathInfo(url);
Stis giving an
request.getRequestDispatcher("/RemServlet").forward(
myReq,
response);
String value=req.getParameter(name) is giving a
but the getParameterNames is working fine
Servlet Error: java.lang.String: java.lang.ClassCastException: java.lang.String
Thanx
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May I help you?
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is name a String object? you haven't created a local class called String have you?
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String value = req.getParameter(name)
getParameter returns an Object, you have to type cast it.
String value = (String)req.getParameter(name)
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andres Gonzalez:
String value = req.getParameter(name)
getParameter returns an Object, you have to type cast it.
String value = (String)req.getParameter(name)



Hi,
By default req.getParameter("name") returns a String Object only. You don't required to type cast it.
Regards,
M.S.Raman
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well
It has to be

hth
MB
[ October 21, 2003: Message edited by: Malhar Barai ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic