The Artima Developer Community
Sponsored Link

Java Answers Forum
Anyone see the error?

2 replies on 1 page. Most recent reply: Nov 14, 2003 4:33 PM by Lynn Hollerman

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Anyone see the error? Posted: Nov 14, 2003 1:06 PM
Reply to this message Reply
Advertisement
I'm trying to run some code I saw used at Javaworld.com, and I get a runtime error in the process, and I'm not sure how to combat it. Here's a snippet of the code:
public static String getRequestParameters(HttpServletRequest aRequest) {
StringBuffer aReturn = new StringBuffer("");
Map m = aRequest.getParameterMap();
Set aEntryS = m.entrySet();
Iterator aEntryI = aEntryS.iterator();
while (aEntryI.hasNext()) {
       Map.Entry aEntry = (Map.Entry) aEntryI.next();
       List aValues = (List) aEntry.getValue();
       for (int i=0; i< aValues.size(); i++) {
            if (aReturn.length()>0) {
                aReturn.append("&");
             }
             aReturn.append(aEntry.getKey());
             aReturn.append("=");
             aReturn.append(aValues.get(i));
       }
       return aReturn.toString();
}


The runtime error I get is a ClassCastException around the "List aValues..." line. I've been over and over this and I don't see the solution - maybe another pair of eyes looking this over could point it out?

Thanks!

Lynn .


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Anyone see the error? Posted: Nov 14, 2003 1:28 PM
Reply to this message Reply
Is the casting being done to java.util.List and not java.awt.List?

Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Re: Anyone see the error? Posted: Nov 14, 2003 4:33 PM
Reply to this message Reply
It's java.util.* that's imported, so I assume java.util.List was what was intended. Hmmm. Maybe they forgot an import?

Flat View: This topic has 2 replies on 1 page
Topic: how to switch from http to https ? Previous Topic   Next Topic Topic: ARGHHHH THIS IB DOSSIER BYTES!!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use