can anyone spot any errors....
<%
// +
// | LEARNING STYLE DATA QUERY
// +
boolean learningstyle =false;
String lstyleresult ="";
int vscore=0;
int ascore=0;
int kscore=0;
for (int i=0;i<visualnos.length;i++)
{
if(arraydata[Integer.parseInt(visualnos[i])-1].equals("Y"))
{
vscore++;
}
}
for (int i=0;i<auditorynos.length;i++)
{
if(arraydata[Integer.parseInt(auditorynos[i])-1].equals("Y"))
{
ascore++;
}
}
for (int i=0;i<doingnos.length;i++)
{
if(arraydata[Integer.parseInt(doingnos[i])-1].equals("Y"))
{
kscore++;
}
}
lstyleresult ="Visual: "+vscore+"/"+visualnos.length+"<br /><br />Audio: "+ascore+"/"+auditorynos.length+"<br /><br />Kinetic: "+kscore+"/"+doingnos.length;
RS=Stmt.executeQuery("select userid from learningstyle where userid='"+sr_studentid+"' order by submitted desc,id desc");
if (RS.first())
{
PreparedStatement statement = ConnStar.prepareStatement("select data from learningstyle where userid='"+sr_studentid+"' order by submitted desc,id desc");
learningstyle =true;
String data = RS.getString("data");
String[] arraydata = data.split(",");
String[] visualnos ={"4","6","8","12","13","17","22","24","25","29","33","35","37"};
String[] auditorynos ={"1","3","9","11","14","16","18","21","26","28","32","36","38"};
String[] doingnos ={"2","5","7","10","15","19","20","23","27","30","31","34","39"};
}
elseif
{
PreparedStatement statement = ConnStar.prepareStatement("select data from learningstyle where userid='"+sr_studentid+"' and input_type='manual' order by submitted desc,id desc");
learningstyle =true;
String data = RS.getString("data");
String[] arraydata = data.split(",");
String[] visualnos ={"1","2","3","4","5","6","7","8","9","10","11","12","13"};
String[] auditorynos ={"14","15","16","17","18","19","20","21","22","23","24","25","26"};
String[] doingnos ={"27","28","29","30","31","32","33","34","35","36","37","38","39"};
}
else
{
learningstyle =false;
}
%>
// line 77
sorry to annoy everyone.... its bugging me it wont work... the following are the two errors im getting.. line 77 at the bottom of the code
org.apache.jasper.JasperException: Unable to compileclassfor JSP
An error occurred at line: 0 in the jsp file: /profiles/includes/learning_style_profile.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\jakarta-tomcat-5.0.18\work\Catalina\localhost\star\profiles\learning_profile_jsp.java:1602:'(' expected
{
^
An error occurred at line: 77 in the jsp file: /profiles/includes/learning_style_profile.jsp
Generated servlet error:
E:\jakarta-tomcat-5.0.18\work\Catalina\localhost\star\profiles\learning_profile_jsp.java:1621: illegal start of expression
out.write("\r\n\r\n");
^
2 errors
[7298 byte] By [
fahafiza] at [2007-11-27 11:32:53]

You have two problems....
The actual errors are on line 1602 and the second on line 1621. Not line 77 as first suggested
> else if
> {
What's that supposed to be?
> You have two problems....
>
> The actual errors are on line 1602 and the second on
> line 1621. Not line 77 as first suggested
I don't know if c0demonk3y is just messing with you or what, but in case it's not clear, lines 1602 and 1621 are in the generated source code, not in the jsp you have control over. The error is in your own code for sure, and it has nothing to do with the line numbers in the generated code.
> I don't know if c0demonk3y is just messing with you
> or what, but in case it's not clear, lines 1602 and
> 1621 are in the generated source code, not in the jsp
> you have control over. The error is in your own code
> for sure, and it has nothing to do with the line
> numbers in the generated code.
Ummm those line numbers are in his code... it even gives the descriptions of the problems i.e. the first one is that it is expecting '{' and got a '(' on line 1602
> Ummm those line numbers are in his code... it even
> gives the descriptions of the problems i.e. the first
> one is that it is expecting '{' and got a '(' on line
> 1602
Umm no, those line numbers refer to the servlet class that was generated from his JSP file.
dwga at 2007-7-29 16:48:00 >

Editing 'cos I'm being extremely dense. Apologies to OP & warnerja.
The error is in the fact you have an else if statement without any parenthesis
Message was edited by:
c0demonk3y
ok, i havent touched line 1602 at all...all i have editted is the above...
what do u mean by parenthesis? how can i fix the statement?
You have written an "else if" without any test statement
i.e. you have written:
if (something = true){
// Some code here
}
else if {
// Some code here
}
else {
// More code
}
Can you see the problem with the second part of the whole if statement?
It should be:
if (something = true) {
// Some code
}
else if (somethingelse = true) {
// More code
}
else {
// etc etc
}
Please note the above is psuedo code and you shouldn't test for true like I have above.
Message was edited by:
c0demonk3y
> You have written an "else if" without any test
> statement
>
> i.e. you have written:
> [code]
> if (something = true){
>// Some code here
> else if {
>// Some code here
> else {
>// More code
> code]
>
> Can you see the problem with the second part of the
> whole if statement?
>
> It should be:
> [code]if (something = true) {
>// Some code
> else if (somethingelse = true) {
>// More code
> else {
>// etc etc
> code]
>
> Please note the above is psuedo code and you
> shouldn't test for true like I have above.
>
> Message was edited by:
> c0demonk3y
Those should be == comparisons, not = assignments.
ah ok...
what im trying to do is run a query with a different string... can i post you the code?
> Those should be == comparisons, not = assignments.
Precisely :)
I'm having one of those days today... NEED more caffiene
> caffiene
That's supposed to be...
Oh, never mind.
* starts smacking head repeatedly *
stupid, stupid brain....
I need a caffeine ;) on an IV drip I think lol
try putting some scotch in your coffee.
> try putting some scotch in your coffee.
See... now why didn't I think of that?!?!
* starts smacking head again *
> > Those should be == comparisons, not = assignments.
>
> Precisely :)
>
> I'm having one of those days today... NEED more
> caffiene
I could have sworn your edit wasn't there when I clicked reply, but then again, I'm only halfway through my first cup.
i'm nearly suicidal....
ok, below is the working code... i want this code to run first... and if a column in mysql table has "manual" in it then i want code 2 STRING to run instead of code 1 string...
CODE1
<%
// +
// | LEARNING STYLE DATA QUERY
// +
boolean learningstyle = false;
String lstyleresult = "";
RS=Stmt.executeQuery("select data from learningstyle where userid='"+sr_studentid+"' order by submitted desc,id desc");
if (RS.first())
{
learningstyle = true;
String data = RS.getString("data");
String[] arraydata = data.split(",");
String[] visualnos = {"4","6","8","12","13","17","22","24","25","29","33","35","37"};
String[] auditorynos = {"1","3","9","11","14","16","18","21","26","28","32","36","38"};
String[] doingnos = {"2","5","7","10","15","19","20","23","27","30","31","34","39"};
int vscore=0;
int ascore=0;
int kscore=0;
for (int i=0;i<visualnos.length;i++)
{
if(arraydata[Integer.parseInt(visualnos[i])-1].equals("Y"))
{
vscore++;
}
}
for (int i=0;i<auditorynos.length;i++)
{
if(arraydata[Integer.parseInt(auditorynos[i])-1].equals("Y"))
{
ascore++;
}
}
for (int i=0;i<doingnos.length;i++)
{
if(arraydata[Integer.parseInt(doingnos[i])-1].equals("Y"))
{
kscore++;
}
}
lstyleresult = "Visual: "+vscore+"/"+visualnos.length+"<br /><br />Audio: "+ascore+"/"+auditorynos.length+"<br /><br />Kinetic: "+kscore+"/"+doingnos.length;
}
else
{
learningstyle = false;
}
%>
CODE2
"select data from learningstyle where userid='"+sr_studentid+"' and input_type='manual' order by submitted desc,id desc"
String[] visualnos = {"1","2","3","4","5","6","7","8","9","10","11","12","13"};
String[] auditorynos = {"14","15","16","17","18","19","20","21","22","23","24","25","26"};
String[] doingnos = {"27","28","29","30","31","32","33","34","35","36","37","38","39"};
can anyone fiddle withthis and return the final code... im far too frustrated... need some majr help
> i'm nearly suicidal....
Here we go again.
~
hey mate its that time of day....
> > i'm nearly suicidal....
>
> Here we go again.
>
> ~
That's disturbing on many levels... lol
Suicidal tendancies are so common here it makes people roll their eyes... Anyways I'm off to cry in a corner and OD on caffeine
> > i'm nearly suicidal....
>
> Here we go again.
>
> ~
Perhaps the competition for IT jobs if finally taking it's toll?
someone must be able to crack the code
> someone must be able to crack the code
Yep. But the whole "I'm going to kill myself, so someone do this for me" shtick is a bit of turn-off. We volunteer to help people here; we do it for free. So when you pass off your death, doom, and gloom onto the forum, it makes it far less fun and entertaining to help. Hopefully, you understand.
~
lol ok im not literally sucidal ha...
ive got the following code to work so far...
but it doesnt display the mySQL results... any suggestions...
<%
// +
// | LEARNING STYLE DATA QUERY
// +
boolean learningstyle = false;
String data = RS.getString("data");
String[] arraydata = data.split(",");
String[] visualnos = {"4","6","8","12","13","17","22","24","25","29","33","35","37"};
String[] auditorynos = {"1","3","9","11","14","16","18","21","26","28","32","36","38"};
String[] doingnos = {"2","5","7","10","15","19","20","23","27","30","31","34","39"};
String man_data = RS.getString("date");
String[] man_arraydata = data.split(",");
String[] man_visualnos = {"1","2","3","4","5","6","7","8","9","10","11","12","13"};
String[] man_auditorynos = {"14","15","16","17","18","19","20","21","22","23","24","25","26"};
String[] man_doingnos = {"27","28","29","30","31","32","33","34","35","36","37","38","39"};
int vscore=0;
int ascore=0;
int kscore=0;
for (int i=0;i<visualnos.length;i++)
{
if(arraydata[Integer.parseInt(visualnos[i])-1].equals("Y"))
{
vscore++;
}
}
for (int i=0;i<auditorynos.length;i++)
{
if(arraydata[Integer.parseInt(auditorynos[i])-1].equals("Y"))
{
ascore++;
}
}
for (int i=0;i<doingnos.length;i++)
{
if(arraydata[Integer.parseInt(doingnos[i])-1].equals("Y"))
{
kscore++;
}
}
int man_vscore=0;
int man_ascore=0;
int man_kscore=0;
for (int i=0;i<man_visualnos.length;i++)
{
if(man_arraydata[Integer.parseInt(man_visualnos[i])-1].equals("Y"))
{
man_vscore++;
}
}
for (int i=0;i<man_auditorynos.length;i++)
{
if(arraydata[Integer.parseInt(man_auditorynos[i])-1].equals("Y"))
{
man_ascore++;
}
}
for (int i=0;i<man_doingnos.length;i++)
{
if(man_arraydata[Integer.parseInt(man_doingnos[i])-1].equals("Y"))
{
man_kscore++;
}
}
String lstyleresult = "";
lstyleresult = "Visual: "+vscore+"/"+visualnos.length+"<br /><br />Audio: "+ascore+"/"+auditorynos.length+"<br /><br />Kinetic: "+kscore+"/"+doingnos.length;
String man_lstyleresult = "";
man_lstyleresult = "Visual: "+man_vscore+"/"+man_visualnos.length+"<br /><br />Audio: "+man_ascore+"/"+man_auditorynos.length+"<br /><br />Kinetic: "+man_kscore+"/"+man_doingnos.length;
RS=Stmt.executeQuery("select data from learningstyle where userid='"+sr_studentid+"' order by submitted desc,id desc");
if (RS.first())
{
learningstyle = true;
PreparedStatement pStmt = ConnStar.prepareStatement("select data from learningstyle where userid='"+sr_studentid+"' order by submitted desc,id desc");
pStmt.executeQuery() ;
pStmt.close();
}
else if(learningstyle==true)
{
learningstyle = true;
PreparedStatement statement = ConnStar.prepareStatement("select data from learningstyle where userid='"+sr_studentid+"' and input_type='manual' order by submitted desc,id desc");
}
else
{
learningstyle = false;
}
%>
> lol ok im not literally sucidal ha...
>
> ive got the following code to work so far...
> but it doesnt display the mySQL results... any
> suggestions...
Yes, write code to actually display the results instead of apparantly expecting magic to happen. You have nothing in that code to display anything -- all you're doing is executing queries and doing basically nothing with the results.
warnerja...
this is the code to display the results... but unfortunatley its stil not displaying... have i missed something?
<div class="round-container round-orange-bg" style="float:right; width:385px;">
<div class="round-top-orange"><img src="../images/orange-tl.jpg" width="14" height="14" alt=" " class="corner" /></div>
<div class="round-title-bar">
<span class="round-title">Learning Style</span>
</div>
<table width="99%" cellpadding="4" cellspacing="0" border="0" style="padding-left:10px;">
<tr>
<%
if (learningstyle==true)
{
out.print("<th class='right'>Graph</th><td><a href='lstyle.jsp?studentid="+sr_studentid+"' target='_blank'>View learning style graph</a></td>");
}
else
{
out.print("<td class='center'>No graphical data recorded. <br /><strong><a href='/intranet/studentzone/learningstyles/' target='_blank'>Click Here</a></strong> to fill out the Learning Style Questionnaire</br></br><strong><a href ='lp_manual_update.jsp?studentid="+sr_studentid+"' onClick='return popup(this)'>Click here to enter score manually</a></strong></td>");
}
%>
</tr>
<%
if (lstyleresult.length()>0)
{
%>
<tr>
<th valign="top" class="right">Score</th>
<td><%=lstyleresult%></td>
</tr>
<%
}
%>
</table>
<div class="round-bottom-orange"><img src="../images/orange-bl.jpg" width="14" height="14" alt=" " class="corner" /></div>
</div>
You're getting a resultset but you're not retrieving any values from the resultset!
This JDBC tutorial will show you how to do this:
http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
WROONG!
You have written an "else if" without any test statement
i.e. you have written:
if (something = true){
// Some code here
}
else if {
// Some code here
}
else {
// More code
}
Can you see the problem with the second part of the whole if statement?
It should be:
if (something = true) {
// Some code
}
else if (somethingelse = true) {
// More code
}
else {
// etc etc
}
Please note the above is psuedo code and you shouldn't test for true like I have above.
Message was edited by:
c0demonk3y
It should be
if (blabla == true) {
not
if(blabla=true) {
that was a bit late. But thanks?
tsitha at 2007-7-29 16:48:10 >

> that was a bit late. But thanks?
Since it came from someone whose username contains 'java', it must be good.
ok... ive got the page to load without errors... but only half of the page loads... is anyone able to speed up what im doing wrong.. im kinda baffled... been looking at it all morning...
being new to jsp doesnt help too... appreciate the efforts from everyone