Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

how to write this code in jsp scriplet

in the jsp scriplet if i write like this i am getting the exception

 Collections.sort(viewChargesList, new Comparator() {
            public int compare(Object o1, Object o2) {
                 return ((String)o1).compareTo((String)o2);
            }
       });

can i write this   public int compare(Object o1, Object o2) function in jsp scriplet or should i use <%! %>
0
chaitu chaitu
Asked:
chaitu chaitu
  • 3
  • 3
1 Solution
 
chaitu chaituAuthor Commented:
05/04/11 19:16:19 java.lang.ClassCastException
05/04/11 19:16:19       at _etrans._ETBBCANCharges$1.compare(_ETBBCANCharges.java:209)
05/04/11 19:16:19       at java.util.Arrays.mergeSort(Arrays.java:1278)
05/04/11 19:16:19       at java.util.Arrays.sort(Arrays.java:1219)
05/04/11 19:16:19       at java.util.Collections.sort(Collections.java:155)
05/04/11 19:16:19       at _etrans._ETBBCANCharges._jspService(_ETBBCANCharges.java:207)
05/04/11 19:16:19       at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
05/04/11 19:16:19       at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:567)
05/04/11 19:16:19       at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:302)
05/04/11 19:16:19       at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
05/04/11 19:16:19       at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
05/04/11 19:16:19       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
05/04/11 19:16:19       at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
05/04/11 19:16:19       at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
05/04/11 19:16:19       at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:220)
05/04/11 19:16:19       at com.foursoft.etrans.servlets.common.ETBreakBulkController.doDispatcher(ETBreakBulkController.java:2093)
05/04/11 19:16:19       at com.foursoft.etrans.servlets.common.ETBreakBulkController.handleDispatching(ETBreakBulkController.java:314)
05/04/11 19:16:19       at com.foursoft.etrans.servlets.common.ETBreakBulkController.doPost(ETBreakBulkController.java:245)
05/04/11 19:16:19       at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
05/04/11 19:16:19       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
05/04/11 19:16:19       at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
05/04/11 19:16:19       at com.foursoft.etrans.common.filter.CredentialFilter.doFilter(CredentialFilter.java:116)
05/04/11 19:16:19       at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
05/04/11 19:16:19       at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
05/04/11 19:16:19       at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
05/04/11 19:16:19       at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
05/04/11 19:16:19       at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
05/04/11 19:16:19       at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
05/04/11 19:16:19       at java.lang.Thread.run(Thread.java:534)
0
 
TimYatesCommented:
That will work, but you are casting o1 and o2 to strings, and your list doesn't contain strings...

that's why you're getting the error...
0
 
chaitu chaituAuthor Commented:
viewChargesList contains arraylist of HouseDocumentCharges object;in that chargeid,chargedesc,paymentmode variables are there;chargeid is string;

i want to sort out the chargeid's;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TimYatesCommented:
instead of

                 return ((String)o1).compareTo((String)o2);

you will need:

                 return ((HouseDocumentCharges)o1).chargeid.compareTo( ((HouseDocumentCharges)o2).chargeid );

then...
0
 
chaitu chaituAuthor Commented:
thanks tim
0
 
TimYatesCommented:
:-)

Good luck!!

Tim
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now