Skip to main content



      Home
Home » Newcomers » Newcomers » Servlet Exception problem
Servlet Exception problem [message #19248] Thu, 27 January 2005 21:57 Go to next message
Eclipse UserFriend
Originally posted by: blian.email.com

I am running Eclipse 3.0.1 and J2sdk 1.4.1_02. I have an applet that calls
a servlet using HttpMessage from O'Reilly. The applet, servlet, and
HTTPMessage compile successfully and create class files. When I run the
applet the servlet is returning an exception immediately without executing a
line of code.

I have used System.out to print to the console each step of the way. I
debugged with breakpoints and everything appears to work correctly. As soon
as the buffer is accessed in HTTPmessage the returned data is an exception
with some unprintable data and a listing of the doGet method in the servlet.
I have reduced the code in the doGet method of the servlet to output a
string using System.out. That is all it does and I still get the exception
from the servlet.

I have looked for logs with possible error messages but I can't find any. I
am stumped. Any help is appreciated.

Here is the relevent code:

Applet
try
{
String league_id = "3";
String draftInfo = "";
URL url = new URL(getCodeBase(), "Draft/DraftStatus.class");
Properties props = new Properties();

props.setProperty("LeagueID",league_id);

// Create a com.oreilly.servlet.HttpMessage to communicate with
that URL
HttpMessage msg = new HttpMessage(url);

// Send a GET message to the servlet, with no query string
// Get the response as an InputStream
InputStream in = msg.sendGetMessage(props);

BufferedReader result = new BufferedReader(new
InputStreamReader(in));
// Read the first line of the response, which should be
// a string representation of the current time
while (result.readLine()!= null)
{
System.out.println(result.readLine());
draftInfo += result.readLine(); // ----->this
contains the exception info
}

// Close the InputStream
in.close();

// Return the retrieved time
return draftInfo;
}
catch (Exception e)
{
// If there was a problem, print to System.out
// (typically the Java console) and return null
e.printStackTrace();
return null;
}
}

}
------------------------------------------------------------ ----------------
---------------------
HTTPMessage relevant code.

public InputStream sendGetMessage(Properties args) throws IOException {
System.out.println("Sending Message");
String argString = ""; // default

if (args != null) {
System.out.println("Has Args");
argString = "?" + toEncodedString(args);
}
System.out.println(argString);
URL url = new URL(servlet.toExternalForm() + argString);

// Turn off caching
URLConnection con = url.openConnection();
con.setUseCaches(false);

return con.getInputStream();
}
------------------------------------------------------------ ----------------
----------------------
Servlet code

package Draft;
import java.io.*;
import java.sql.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class DraftStatus extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException {
System.out.println("IN DOGET");
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
doGet(request, response);
}
}
Re: Servlet Exception problem [message #24698 is a reply to message #19248] Thu, 03 February 2005 21:01 Go to previous message
Eclipse UserFriend
Originally posted by: blian.email.com

Since no one here seems to be able to help can someone point me to a place
where I can get help?
Previous Topic:problem with writing plugins
Next Topic:Could not find Main Class
Goto Forum:
  


Current Time: Thu May 08 19:20:30 EDT 2025

Powered by FUDForum. Page generated in 0.07846 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top