Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet to servlet communication

 
Bob Epling
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I am having a problem gettin a servlet to compile properly. The problem seems to be in
my definition of the ObjectInputStream ois..
I wanted to create an input object to accept
an object from an applet I have created then
call a method to access a database and return
a vector containing the resultset of a query.
Can anyone help with this?
The applet I wrote compiled fine.
Thanks in advance.
Bob Epling
303-971-1835
Here is the servlet code where the problem is:
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
Vector appletData;
Vector dataSet;

try
{
appletData = new Vector();
ObjectInputStream ois = new ObjectInputStream(request.getInputStream());
appletData = (Vector)ois.readObject();
if (appletData.contains("initialQuery"))
{
initialQuery();
}
else
{
System.out.println("appletData didn't have initialQuery");
}

}
catch (IOException e6)
{
System.out.println("IOException: " + e6);
}

ois.close();
ois.flush();
And here is the error generated:
CqtdbConnect2.java:56: Exception java.lang.ClassNotFoundException must be caught, or it mu
st be declared in the throws clause of this method.
appletData = (Vector)ois.readObject();
^
CqtdbConnect2.java:72: Undefined variable or class name: ois
ois.close();
^
CqtdbConnect2.java:73: Undefined variable or class name: ois
ois.flush();
^
CqtdbConnect2.java:77: Variable dataSet may not have been initialized.
oos.writeObject(dataSet);
^
CqtdbConnect2.java:131: Variable dataSet may not have been initialized.
return (dataSet);
^
Note: CqtdbConnect2.java uses a deprecated API. Recompile with "-deprecation" for details
.
5 errors, 1 warning
[done in 6019 ms]
 
paul wheaton
Trailboss
Pie
Posts: 21745
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the first error, put a try catch block around that line. If you get an exception, dump it to System.out.println() so you can see it in the servlet log file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic