Advertisement

07.16.2008 at 08:48AM PDT, ID: 23570135 | Points: 125
[x]
Attachment Details

How to convert String Object into HashMap Object

Asked by babulu in Java Programming Language, Java Server Pages (JSP), Java Standard Edition

Tags: sun, Collections, Java1.5

I sent HashMap object through URL parameter, from JSP into action class. like this
  "/search.jsp?data="+objName

when I am trying to fetch that value in Action class using --  request.getParameter(" obj") --- it is giving String rather than HashMap object.

I want to typecast  that String again into HashMap object so that i can iterate and fetch the HashMap object values.  Is there a way to get the solution.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
Map map =  new HashMap();
 Object obj = new Object();
 String str = request.getParameter("data");
 obj = (Object)str;
 map = (HashMap) obj;   // line 10
 
No compile time errors, but while running its giving
"javax.servlet.ServletException: java.lang.ClassCastException: java.lang.String"  ---> indicating toward line number 10
 
Loading Advertisement...
 
[+][-]07.16.2008 at 09:30AM PDT, ID: 22017552

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 09:33AM PDT, ID: 22017576

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 09:38AM PDT, ID: 22017620

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 09:42AM PDT, ID: 22017660

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:17AM PDT, ID: 22018057

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:20AM PDT, ID: 22018092

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:32AM PDT, ID: 22018202

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:40AM PDT, ID: 22018271

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:47AM PDT, ID: 22018328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:10AM PDT, ID: 22018572

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:14AM PDT, ID: 22018613

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:54AM PDT, ID: 22018958

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 01:38PM PDT, ID: 22019898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 06:41AM PDT, ID: 22269292

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628