<commit_before>package org.scalatra

import javax.servlet._
import javax.servlet.http._
import scala.util.DynamicVariable
import scala.util.matching.Regex
import scala.collection.mutable.HashSet
import scala.collection.JavaConversions._
import scala.xml.NodeSeq

abstract class ScalatraServlet
  extends HttpServlet
  with ScalatraKernel
  with Initializable
{
  import ScalatraKernel._

  override def service(request: HttpServletRequest, response: HttpServletResponse) = handle(request, response)

  /**
   * Defines the request path to be matched by routers.  The default 
   * definition is optimized for `path mapped` servlets (i.e., servlet 
   * mapping ends in `&#47;*`).  The route should match everything matched by
   * the `&#47;*`.  In the event that the request URI equals the servlet path 
   * with no trailing slash (e.g., mapping = `/admin&#47;*`, request URI = 
   * '/admin'), a '/' is returned.
   *
   * All other servlet mappings likely want to return request.getServletPath.
   * Custom implementations are allowed for unusual cases.
   */
  def requestPath = request.getPathInfo match {
    case pathInfo: String => pathInfo
    case null => "/"
  }

  protected var doNotFound: Action = () => {
    response.setStatus(404)
    if (isDevelopmentMode)
      response.getWriter println "Requesting %s %s but only have: %s".format(
        request.getMethod,
        request.getRequestURI,
        routes.entryPoints.mkString("<ul><li>", "</li><li>", "</li></ul>"))
  }

  def servletContext: ServletContext = getServletContext

  type Config = ServletConfig

  private var _kernelName: String = _
  def kernelName = _kernelName

  override def init(config: ServletConfig) = {
    super.init(config)<commit_msg>Improve notFound default error message by displaying the servlet path<commit_after>package org.scalatra

import javax.servlet._
import javax.servlet.http._
import scala.util.DynamicVariable
import scala.util.matching.Regex
import scala.collection.mutable.HashSet
import scala.collection.JavaConversions._
import scala.xml.NodeSeq

abstract class ScalatraServlet
  extends HttpServlet
  with ScalatraKernel
  with Initializable
{
  import ScalatraKernel._

  override def service(request: HttpServletRequest, response: HttpServletResponse) = handle(request, response)

  /**
   * Defines the request path to be matched by routers.  The default 
   * definition is optimized for `path mapped` servlets (i.e., servlet 
   * mapping ends in `&#47;*`).  The route should match everything matched by
   * the `&#47;*`.  In the event that the request URI equals the servlet path 
   * with no trailing slash (e.g., mapping = `/admin&#47;*`, request URI = 
   * '/admin'), a '/' is returned.
   *
   * All other servlet mappings likely want to return request.getServletPath.
   * Custom implementations are allowed for unusual cases.
   */
  def requestPath = request.getPathInfo match {
    case pathInfo: String => pathInfo
    case null => "/"
  }

  protected var doNotFound: Action = () => {
    response.setStatus(404)
    if (isDevelopmentMode){
      val error = "Requesting \"%s %s\" on servlet \"%s\" but only have: %s"
      response.getWriter println error.format(
        request.getMethod,
        request.getPathInfo,
        request.getServletPath,
        routes.entryPoints.mkString("<ul><li>", "</li><li>", "</li></ul>"))
    }
  }

  def servletContext: ServletContext = getServletContext

  type Config = ServletConfig

  private var _kernelName: String = _
  def kernelName = _kernelName

  override def init(config: ServletConfig) = {
    super.init(config)
{'fraction_non_alphanumeric': 0.10097087378640776, 'fraction_numerical': 0.0049930651872399446, 'mean_word_length': 3.6589147286821704, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5996286', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1014, 'n_words': 331}