diff options
author | buraq <buraq@epfl.ch> | 2004-07-26 15:39:02 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-07-26 15:39:02 +0000 |
commit | 0437311aa103119c733f37d0f949da4686b66f15 (patch) | |
tree | d6e50cb4b3e98cc1e55f53c2714870af6b066efb | |
parent | e23c51b0c495f739120309ceaecb264ff5e26cde (diff) | |
download | scala-0437311aa103119c733f37d0f949da4686b66f15.tar.gz scala-0437311aa103119c733f37d0f949da4686b66f15.tar.bz2 scala-0437311aa103119c733f37d0f949da4686b66f15.zip |
fix
-rw-r--r-- | sources/scala/tools/servlet/ScalaServlet.scala | 33 | ||||
-rw-r--r-- | sources/scala/tools/servlet/ServletException.scala | 12 |
2 files changed, 20 insertions, 25 deletions
diff --git a/sources/scala/tools/servlet/ScalaServlet.scala b/sources/scala/tools/servlet/ScalaServlet.scala index f3aabd9bf9..627824f094 100644 --- a/sources/scala/tools/servlet/ScalaServlet.scala +++ b/sources/scala/tools/servlet/ScalaServlet.scala @@ -4,15 +4,11 @@ import java.io.IOException; import scala.xml._; import scala.collection.mutable.HashMap ; import http.HttpOutputStream; -// import scala.collection.mutable.HashMap -// val x = new HashMap[String,String] -// x.update("key","value"); -// x.get("key") match { -// case Some( value ) => ... -// case None => ... -// } x("key") +/** subclasses can be registered with the servlet engine to handle requests + */ abstract class ScalaServlet { + var output:HttpOutputStream = null; // HashMap[String,String] def doGetXML(info: HashMap[String,String]): scala.xml.Node ; @@ -22,18 +18,23 @@ abstract class ScalaServlet { out.write( doGetXML( info ).toString() ); } catch { - case sException:ServletException => ReturnException( sException.returnType(),sException.returnInfo()); - case ex:Exception => ReturnException(30,""); + case ServletException(status, msg) => + showError( status, msg ); + case ex:Exception => + showError(Status.INTERNAL_ERROR, ex.getMessage()); } } - final def ReturnException(code:int, detail :String):unit={ - var info = new HashMap[String,String]; - info.update("code", SERVLET.getCodeMessage(code) ); - info.update("detail", detail); - new ExcepServlet().doGet(output, info); - return null; - + final def showError(status:int, msg :String): scala.xml.Node = { + <html> + <head> + <title>SERVLET ERROR</title> + </head> + <body> + <big>Attention,erreur dans la servlet</big> + <br/>type de l erreur: { Status.getMessage(status) }<br/>{ msg } + </body> + </html> } } diff --git a/sources/scala/tools/servlet/ServletException.scala b/sources/scala/tools/servlet/ServletException.scala index 8a9ba9e032..b92ec2f956 100644 --- a/sources/scala/tools/servlet/ServletException.scala +++ b/sources/scala/tools/servlet/ServletException.scala @@ -1,13 +1,7 @@ package scala.tools.servlet; -import java.io._; -import java.util._; -import java.lang.Math._; -import scala.xml._; -class ServletException(typ:int,info:String) extends Exception{ - def returnType():int={typ;} - def returnInfo():String={info;} - -} + +case class ServletException(code:int, msg:String) extends Exception; + |