Fetch the scala servlet sample using git:
dims@dims-laptop-520:~$ git clone git://github.com/dims/scala-servlet.git
Take a peek at the servlet code:
package org.peat.scalaservlet
import javax.servlet.http._
import javax.servlet._
class Example extends HttpServlet {
override def doGet(request: HttpServletRequest, response: HttpServletResponse) = response.getWriter().println( exampleContent )
def exampleContent(): String = { "Hello world, from a Scala servlet!" }
}
Build the sample using maven:
dims@dims-laptop-520:~/scala-servlet$ mvn war:war
Follow instructions from the following url to deploy the ScalaServlet.war:
http://davanum.wordpress.com/2011/10/08/quick-start-for-websphere-liberty-profile-deploying-a-war/
Don’t forget to enable the servlet feature in the defaultServer/server.xml. Once the server is started peek at the logs
dims@dims-laptop-520:~/wlp$ cat ./usr/servers/defaultServer/logs/trace_12.05.04_22.50.54.0.log [04/May/2012 22:50:54:141 -0700] 00000001 * id= .ibm.ws.kernel.launch.internal.platform.FrameworkManagerImpl [AUDIT ] CWWKE0001I: The kernel was launched. [04/May/2012 22:50:55:645 -0700] 0000001d * id= com.ibm.ws.kernel.feature.internal.FeatureManager [AUDIT ] CWWKF0007I: A feature update is starting after 1.735 seconds. [04/May/2012 22:50:55:682 -0700] 00000001 * id= .ibm.ws.kernel.launch.internal.platform.FrameworkManagerImpl [AUDIT ] CWWKE0002I: The kernel started after 1.774 [04/May/2012 22:50:56:263 -0700] 00000016 * id= com.ibm.ws.app.manager.internal.AppManagerConfigurator [AUDIT ] CWWKZ0058I: Application monitor started after 2.353 seconds. [04/May/2012 22:50:56:265 -0700] 0000001d * id= com.ibm.ws.kernel.feature.internal.FeatureManager [AUDIT ] CWWKF0008I: The feature update is complete after 2.356 seconds. [04/May/2012 22:50:56:314 -0700] 0000001f * id= com.ibm.ws.tcpchannel.internal.TCPChannel [AUDIT ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host localhost (IPv4: 127.0.0.1) port 9080. [04/May/2012 22:50:56:805 -0700] 00000020 * id= com.ibm.ws.http.internal.VirtualHostImpl [AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/ScalaServlet/* [04/May/2012 22:50:56:811 -0700] 00000020 * id= com.ibm.ws.webcontainer.osgi.WebContainer [AUDIT ] SRVE9998A: Application ScalaServlet added to web container. [04/May/2012 22:50:56:814 -0700] 00000020 * id= com.ibm.ws.app.manager.internal.ApplicationImpl [AUDIT ] CWWKZ0001I: The application ScalaServlet has started successfully.
All’s well, now just point your browser to http://localhost:9080/ScalaServlet/