Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Whats going wrong here?

Posted on 2006-11-21
12
Medium Priority
?
250 Views
Last Modified: 2012-05-05
string updated;
updated = "blah,blah";
String temp;
String temp_second;
temp = updated.split(',');


Im not really familar with JSP, do I need to import a special library or something to get this to work?
0
Comment
Question by:fox_statton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
12 Comments
 
LVL 5

Expert Comment

by:deeppra
ID: 17986065
put like this
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
<%
String updated;
updated = "blah,blah";
String temp;
String temp_second;
temp = updated.split(',');
%>
</body>
</html>


What u want to print?? ist temp??
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986070
do u get any errors??
0
 

Author Comment

by:fox_statton
ID: 17986106
Hi, its part of a larger script, but it seems that the

temp[] = updated.split(',');

is giving an error:

Unable to compile class for JSP An error occurred between lines: 16 and 38 in the jsp


cannot resolve symbol symbol : method split (char) location: class java.lang.String String temp[] = updated.split(','); ^ 1
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!

 
LVL 5

Expert Comment

by:deeppra
ID: 17986118
decalre it as an array
String[] temp
then itwill be okay
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 17986430
Another issue might be JDK support. If you are compiling/running on a JDK version 1.3 or older, it will not support the String.split() method which was only introduce in JDK 1.4. You are also trying to use a char ('single quotes') rather than the String("double quotes") in the regex of the String.split method.

string updated = "blah,blah";
String[] temp = updated.split(",");

Should work fine assuming that your JDK is 1.4+.
0
 

Author Comment

by:fox_statton
ID: 17986504
If my JDK isnt 1.4+ is there another way to split?
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986590
you can use StringTokenizer class for splitting the string
refer this doc
http://java.sun.com/j2se/1.3/docs/api/java/util/StringTokenizer.html
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 17986592
You have to use the more cumbersome StringTokenizer

    String aString = "word1,word2,word3";
    StringTokenizer parser = new StringTokenizer(aString, ",");
    while (parser.hasMoreTokens()) {
        //do stuff here
        processWord(parser.nextToken()); //this nextToken() method returns a String
    }
0
 

Author Comment

by:fox_statton
ID: 17986704
Hi,
I ve managed to get it working... kinda...


String updated = "November 20,2006";
String[] temp = updated.split(",");
String[] temp_second = temp[0].split(" ");
updated = temp_second[1]+" "+temp_second[2]+" "+temp[1];

out.println(updated);

the problem is that updated is coming out as "November 2006" instead of "20 November 2006"

Any ideas?
0
 

Author Comment

by:fox_statton
ID: 17986923
Ok, so I figure its something to do with the fact that those two arrays have integers, so I tried a different approach, but its still not working:

String[] temp = updated.split(" ");
Int[] tempint = updated.split(" ");
out.println(tempint[1]);
out.println(temp[0]);
out.println(tempint[2]);
0
 
LVL 5

Accepted Solution

by:
deeppra earned 1952 total points
ID: 17987152
>>String updated = "November 20,2006";
>>String[] temp = updated.split(",");
>>String[] temp_second = temp[0].split(" ");
>>updated = temp_second[1]+" "+temp_second[2]+" "+temp[1];

should be like this
String updated = "November 20,2006";
String[] temp = updated.split(",");
String[] temp_second = temp[0].split(" ");
updated = temp_second[1]+" "+temp_second[0]+" "+temp[1];
0
 

Author Comment

by:fox_statton
ID: 18002769
Hi,
its still not working :(
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
This week I attended a Startup Week Chattanooga talk on Gender Diversity in Technology. Check out what I learned.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question