wood burning stoves 2.0*
The moose likes JSP and the fly likes weird error log Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "weird error log" Watch "weird error log" New topic
Author

weird error log

nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
gud evening guys, um, i had a jsp code written like this...
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*, java.sql.*" %>
<%@ page language="java" import="acts.*"%>
<html>
<head>
<%
System.out.println("display artifact");
String InputString = request.getParameter("InputString");
String IDacquired = request.getParameter("IDtransfer");
long IDtransfer = Long.parseLong(IDacquired);
long[] ArrayOfID = null;
int IDcounter = 0;
ACTSDatabase DB = new ACTSDatabase();
ACTSUser user = new ACTSUser(DB);
ArtifactText Data = new ArtifactText(user,DB);
ACTSExplorer tc = new ACTSExplorer();
ArtifactContainer Show = new ArtifactContainer(user,DB);
Show = tc.AccessArtifacts();
%>
<%
public void DisplayArtifact(JspWriter out) throws IOException
{
}

%>

<title>View Files for the <%= request.getParameter("NameTransfer") %>Artifact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#f4f4f4" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0">
<p><font color="#003300" face="Arial, Helvetica, sans-serif">Artifact</font> </p>
<table width="50%" border="1" align="center" bordercolor="#006600">
<tr>
<%out.println(InputString);%>
<%out.println(IDacquired);%>
</tr>
</table>
</body>
</html>
whenever i tested this a browser the error show this line...
500 Servlet Exception
Note: sun.tools.javac.Main has been deprecated.
/DisplayArtifact.jsp:40: '}' expected.
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
^
/DisplayArtifact.jsp:28: Statement expected.
public void DisplayArtifact(JspWriter out) throws IOException
^
/DisplayArtifact.jsp:39: Identifier expected.
pageContext.write(_jsp_string2, 0, _jsp_string2.length);
^
3 errors, 1 warning
for some reason the error is found in 'public void DisplayArtifact(JspWriter out) throws IOException
{
}' in which i didn't even put anything inside yet..
could you help me out on this one guys....


if you have helped me in my questions, whether dumb or hard.. all i could say is...<br />YOU'RE THE MAN/WOMAN!!!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You've put the method declaration inside a scriptlet tag and not a declaration tag.
Try:

(Note the added exclaimation mark in the tag)
Dave
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
tnx, tnx, a lot... there are no words indeed..
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459


Sure there are
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
hehe, new errors created... here is the code i did..
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*, java.sql.*" %>
<%@ page language="java" import="acts.*"%>
<html>
<head>
<%
System.out.println("display artifact");
String InputString = request.getParameter("InputString");
String IDacquired = request.getParameter("IDtransfer");
%>
<%!
long IDtransfer = Long.parseLong(IDacquired);
long[] ArrayOfID = null;
int IDcounter = 0;
ACTSDatabase DB = new ACTSDatabase();
ACTSUser user = new ACTSUser(DB);
ArtifactText Data = new ArtifactText(user,DB);
ACTSExplorer tc = new ACTSExplorer();
ArtifactContainer Show = new ArtifactContainer(user,DB);
public void DisplayArtifact(JspWriter out) throws IOException
{ long IDkeeper = Long.parseLong(IDacquired);
int i;
Parse(out,InputString);

out.println("</tr>");
out.println("<tr>");
for(i=0;i<IDcounter;i++)
{
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\">"+Data.GetTreeValue(ArrayOfID[i])+"</font></div></td>");
}
}
%>
<%
Show = tc.AccessArtifacts();
%>
<title>View Files for the <%= request.getParameter("NameTransfer") %>Artifact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#f4f4f4" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0">
<p><font color="#003300" face="Arial, Helvetica, sans-serif">Artifact</font> </p>
<table width="50%" border="1" align="center" bordercolor="#006600">
<tr>
<%out.println(InputString);%>
<%out.println(IDacquired);%>
</tr>
</table>
</body>
</html>
ok so i did the thing you had said to me... and when i did put the '!' mark,, here's what happen..
500 Servlet Exception
Note: sun.tools.javac.Main has been deprecated.
/DisplayArtifact.jsp:14: Undefined variable: IDacquired
long IDtransfer = Long.parseLong(IDacquired);
^
/DisplayArtifact.jsp:38: Undefined variable: IDacquired
{ long IDkeeper = Long.parseLong(IDacquired);
^
/DisplayArtifact.jsp:42: Undefined variable: InputString
Parse(out,InputString);
^
/DisplayArtifact.jsp:56: Exception java.sql.SQLException must be caught,
or it must be declared in the throws clause of this method.
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica,
sans-serif\">"+Data.GetTreeValue(ArrayOfID[i])+"</font></div></td>");

^
4 errors, 1 warning
and when i tried to combined all of them in a single <%! %> quote here's what it showed me...
Note: sun.tools.javac.Main has been deprecated.
/DisplayArtifact.jsp:12: Undefined variable or class name: request
String InputString = request.getParameter("InputString");
^
/DisplayArtifact.jsp:14: Undefined variable or class name: request
String IDacquired = request.getParameter("IDtransfer");
^
/DisplayArtifact.jsp:46: Method Parse(javax.servlet.jsp.JspWriter, java.lang.String)
not found in class _displayartifact__jsp.
Parse(out,InputString);
^
/DisplayArtifact.jsp:60: Exception java.sql.SQLException must be caught,
or it must be declared in the throws clause of this method.
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica,
sans-serif\">"+Data.GetTreeValue(ArrayOfID[i])+"</font></div></td>");

^
4 errors, 1 warning
WAaAAaaAH, there...
um, what's the Exception problem in the 4th error? and how will i used the 'request' method in the <%! %> quote?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm still looking at your code, but you should be aware that creating instance variables (ie variables inside the <%! tag) means your code is not thread safe.
Multiple requests go through a single instance of a JSP (and Servlet) at the same time, and it is possible for one thread to set a value and have another thread set it to something else before that value is used.
Just a warning...
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Depending on the server you are using, it would be useful if you could find the java source created from your code and look at that.
It will look something like this:

The point to all this is that the variable IDacquired is local to the _jspService method (and is thread-safe), but the variable IDtransfer is an instance variable and the line that declares it cannot se the variable IDacquired. It is not 'in scope'.
The first step is to make the declaration tag as small as possible. As a general rule, never put variables there unless you are aware of the implications.
Hope this helps.
Dave
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
ok,ok, i got it.. to be honest, i only learned JSP through experience and examples, i haven't learned through reading books and doing some exercise, i learned through the example of other people's work and learning from it...
what i really wanted to do was to get the values from a previous JSP (named explorerbeta.jsp) and use it to this JSP(named DisplayArtifact.jsp).
and the codeline for that is:
<% out.println("<a href=\"DisplayArtifact.jsp?IDtransfer="+Show.GetArtID(i)+"&NameTransfer="+Show.GetName(i)+"&InputString="+InputString[i]+"\" target=\"right\">"+Show.GetName(i)+"</a></div>"); %>
there,, explorerbeta.jsp links DisplayArtifact.jsp, when DisplayArtifact.jsp is called it also pass the values of IDtransfer, NameTransfer, and InputString from explorerbeta.jsp,
questions is, how will access these values from explorerbeta.jsp to use it from DisplayArtifact.jsp and manipulate it jsp?
oh, btw, im using resin as my testing server... also do u have any ideas how to find the jave code created from my code?
Dave, thanks a lot from your patience and kindness...
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by nene batungbakal:
oh, btw, im using resin as my testing server... also do u have any ideas how to find the jave code created from my code?

I've never use Resin, but see if this helps:
Keeping the generated jsp java files
what i really wanted to do was to get the values from a previous JSP (named explorerbeta.jsp) and use it to this JSP(named DisplayArtifact.jsp)
Try something like this, it gets rid of the need for methods and instance variables. You won't have a declaration block either...
It's based on the fact you can just into and out of scriptlets in your JSPs

We let the scriptlet tags wrap the Java code so that everything else is treated as HTML, and we can mix the two. The trick is not to get too clever since it becomes difficult to debug or maintain...
Dave
[ July 23, 2003: Message edited by: David O'Meara ]
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
ok ok, tnx again,
um,,, i forgot to write another function needed to complete the jsp file (DisplayArtifact.jsp)here is the complete code for the file(the non unedited version yet... the one full of errors...)
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*, java.sql.*" %>
<%@ page language="java" import="acts.*"%>

<%
System.out.println("afasdfas");
System.out.println(InputString + "afasdfas");
ACTSDatabase DB = new ACTSDatabase();
ACTSUser user = new ACTSUser(DB);
ArtifactText Data = new ArtifactText(user,DB);
ArtifactContainer Show = new ArtifactContainer(user,DB);

String InputString = request.getParameter("InputString");
System.out.println(InputString + "afasdfas");
long[] ArrayOfID = null;
int IDcounter = 0;
%>
<%

public ArtifactContainer TestDisplay(){
ACTSExplorer tc = new ACTSExplorer();
ArtifactContainer container = new ArtifactContainer(tc.user,tc.db);
container = tc.AccessArtifacts();
return(container);
}

public void Parse(JspWriter out, String Input) throws IOException
{ int index;
int start,finish;
int i;
long ParsedArtID;

if (Input.length() > 0)
{//temp = Input;
start=1;
for (index=1;index<Input.length();index++)
{if (Input.charAt(index) == '@')
{ finish = index;
ParsedArtID = Long.parseLong(Input.substring(start,finish));
i=0;
while (Show.GetArtID(i) != ParsedArtID && i<Show.GetLength())
{ i++;
}
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\">"+Show.GetName(i)+"</font></div></td>");
ArrayOfID[IDcounter] = ParsedArtID;
IDcounter++;
start = finish+1;
}
}
}
}
public void DisplayArtifact(JspWriter out) throws IOException
{ long IDkeeper = Long.parseLong(request.getParameter("IDtransfer"));
int i;
Parse(out,InputString);

out.println("</tr>");
out.println("<tr>");
for(i=0;i<IDcounter;i++)
{
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\">"+Data.GetTreeValue(ArrayOfID[i])+"</font></div></td>");
}

}

%>
<html>
<head>
<title>View Files for the <%=request.getParameter("NameTransfer")%> Artifact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<% Show = TestDisplay(); %>
<body bgcolor="#f4f4f4" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0">
<p><font color="#003300" face="Arial, Helvetica, sans-serif">Artifact</font> </p>
<table width="50%" border="1" align="center" bordercolor="#006600">
<tr>
<%DisplayArtifact(out); %>
</tr>
</table>
</body>
</html>
there,
i have made two functions for it, the DisplayArtifact function prints the value of Data.GetTreeValue(ArrayOfID[i])in a single cell of a table, but before that function can do that it first call the function Parse, the Parse function parses first the InputString variable which is passed from the previous jsp(explorerbeta2.jsp i have explained this from my previous msgs) because InputString contains something like this... (@2897@7890@8905@8908@) which is a string where the Parse function concutenates the '@' character and gets the '2897'string and save it to ParsedArtID, but before he save it to ParsedArtID, ParsedArtID first convert it to a long datatype from a string datatype. After the conversion, ParsedArtID was saved to ArrayOfID[IDCounter] where ArrayOfID was an array of long datatype, and IDCounter is an int type that counts the InputString to be parsed (ie @2897@7890@8905@8908@ then IDCounter = 4)... that my true intentions... hope u understand it.. now when i did the thing u told me to... like this..
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*, java.sql.*" %>
<%@ page language="java" import="acts.*"%>
<html>
<head>
<%!
public int Parse(JspWriter out, String Input, int IDcounter, ArtifactContainer Show) throws IOException
{ int index;
int start,finish;
int i;
long ParsedArtID;

if (Input.length() > 0)
{//temp = Input;
start=1;
for (index=1;index<Input.length();index++)
{if (Input.charAt(index) == '@')
{ finish = index;
ParsedArtID = Long.parseLong(Input.substring(start,finish));
i=0;
while (Show.GetArtID(i) != ParsedArtID && i<Show.GetLength())
{ i++;
}
out.println("<td><div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\">"+Show.GetName(i)+"</font></div></td>");
ArrayOfID[IDcounter] = ParsedArtID;
IDcounter++;
start = finish+1;
}
}
}
return(IDcounter);
}
%>
<title>View Files for the <%= request.getParameter("NameTransfer") %>Artifact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#f4f4f4" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0">
<p><font color="#003300" face="Arial, Helvetica, sans-serif">Artifact</font> </p>
<%
System.out.println("display artifact");
String InputString = request.getParameter("InputString");
String IDacquired = request.getParameter("IDtransfer");
long IDtransfer = Long.parseLong(IDacquired);
long[] ArrayOfID = null;
int IDcounter = 0;
int i;
ACTSDatabase DB = new ACTSDatabase();
ACTSUser user = new ACTSUser(DB);
ArtifactText Data = new ArtifactText(user,DB);
ACTSExplorer tc = new ACTSExplorer();
ArtifactContainer Show = new ArtifactContainer(user,DB);
Show = tc.AccessArtifacts();

%>
<table width="50%" border="1" align="center" bordercolor="#006600">
<tr>
<%=InputString%>
<%=IDacquired%>
</tr>
<tr>
<% IDcounter = Parse(out,InputString,IDcounter,Show)%>
</tr>
<tr>
<%
for(i=0;i<IDcounter;i++)
{
%>
<td><div align="center"><font face="Arial, Helvetica, sans-serif"><%=Data.GetTreeValue(ArrayOfID[i])%></font></div></td>
<%}%>
</tr>
</table>
</body>
</html>
i forgot to add the function Parse in the optimized u taught me,... so it created errors from the generated output.. can u help me optimized my code with the function Parse added in it?... please...
Dave please do extend your patience some more for me... sori ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: weird error log