Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

learning servlets but getting IOException error  RSS feed

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first servlet and I can't get the thing to compile. Can anyone offer me some direction? Thank you.

From C:\workspace\test, I run: javac HelloServlet.java

CLASSPATH=.;C:\workspace\test;C:\workspace\apotheke;C:\Program Files\apache-tomcat-5.5.17\common\lib\servlet-api.jar;C:\Program Files\apache-tomcat-5.5.17\common\lib\jsp-api.jar



Here is my error:
C:\workspace\test>javac HelloServlet.java
HelloServlet.java:19: unreported exception java.io.IOException; must be caught or declared to be thrown
PrintWriter out = response.getWriter();
^
1 error
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're properly handling the IOException, except that your "try" block is missing its closing brace, right before the keyword "catch".
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is more a core Java question than a servlet specific one, moving to Java in General (Beginner)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!