This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Using html namespace in a servlet
- From: Per Bothner <per at bothner dot com>
- To: Kawa mailing list <kawa at sourceware dot org>, Sunder Swaminathan <u89012 at gmail dot com>
- Date: Thu, 18 Feb 2016 22:59:58 -0800
- Subject: Re: Using html namespace in a servlet
- Authentication-results: sourceware.org; auth=none
I received this message:
Iâm new to Kawa and loving every bit of it so far! Iâm playing around writing servlets but canât seem to get the built in html namespace to generate some html output. Any ideas what might be going on? Iâve pasted the code and the exception below. Thank you for any help!
âservlets.scmâ
(define-alias HttpServlet javax.servlet.http.HttpServlet)
(define-alias HttpServletRequest javax.servlet.http.HttpServletRequest)
(define-alias HttpServletResponse javax.servlet.http.HttpServletResponse)
(define-simple-class <a.Foo> (HttpServlet)
((service (r :: HttpServletRequest) (w :: HttpServletResponse))
; ((w:getWriter):write "OK"))) ;this works fine
((w:getWriter):write (*:toString (html:p "here"))))) ;but this fails
And the exception Iâm seeing (while running under Tomcat 9.0.0.M1)
HTTP Status 500 - Servlet execution threw an exception
*type* Exception report
*message* _Servlet execution threw an exception_
*description* _The server encountered an internal error that prevented it from fulfilling this request._
*exception*
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
*root cause*
java.lang.IllegalAccessError: tried to access field servlets.Lit0 from class a.Foo
a.Foo.service(servlets.scm:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
I don't know how you "deployed" your servlet - you should normaly
show the command-line or compilation options you used, as well ins how
you stalled something
However, I'm guessing the problem is almost certainly confusion between
the explicit class a.Foo vs the "module class" generated from the entire source file.
The following has more detail than you need, but it explains the idea of module classes:
http://www.gnu.org/software/kawa/Module-classes.html
It is possible to have a module class and an explicit class (defined by define-simple-class)
be the same class, as described in the above link.
Alternatively, follow the guide in:
http://www.gnu.org/software/kawa/Server-side-scripts.html
http://www.gnu.org/software/kawa/Self-configuring-page-scripts.html
http://www.gnu.org/software/kawa/Servlets.html
--
--Per Bothner
per@bothner.com http://per.bothner.com/