org.scalatra.servlet
Members list
Type members
Classlikes
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
AsyncSupport.type
Attributes
- Companion
- object
- Supertypes
-
trait ScalatraAsyncSupporttrait ServletBasetrait ScalatraBasetrait TypeConverterSupporttrait ScalatraParamsImplicitstrait Initializabletrait DynamicScopetrait RequestResponseScopetrait CoreDsltrait Controltrait Handlertrait ScalatraContexttrait CookieContexttrait SessionSupporttrait ServletApiImplicitsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait FutureSupport
Adapts for handling servlet objects (e.g., ServletRequest, HttpSession, ServletContext) as mutable map.
Adapts for handling servlet objects (e.g., ServletRequest, HttpSession, ServletContext) as mutable map.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
FileMultiParams.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
FileUploadSupport can be mixed into a org.scalatra.ScalatraFilter or org.scalatra.ScalatraServlet to provide easy access to data submitted as part of a multipart HTTP request. Commonly this is used for retrieving uploaded files.
FileUploadSupport can be mixed into a org.scalatra.ScalatraFilter or org.scalatra.ScalatraServlet to provide easy access to data submitted as part of a multipart HTTP request. Commonly this is used for retrieving uploaded files.
Once the trait has been mixed into your handler, you need to enable multipart configuration in your ''web.xml'' or by using @MultipartConfig
annotation. To configure in ''web.xml'' add <multipart-config />
to your <servlet>
element. If you prefer annotations instead, place @MultipartConfig
to your handler. Both ways provide some further configuration options, such as specifying the max total request size and max size for invidual files in the request. You might want to set these to prevent users from uploading too large files.
When the configuration has been done, you can access any files using fileParams("myFile")
where ''myFile'' is the name of the parameter used to upload the file being retrieved. If you are expecting multiple files with the same name, you can use fileMultiParams("files[]")
to access them all.
To handle any errors that are caused by multipart handling, you need to configure an error handler to your handler class:
import org.scalatra.servlet.SizeLimitExceededException
import org.scalatra.servlet.FileUploadSupport
@MultipartConfig(maxFileSize=1024*1024)
class FileEaterServlet extends ScalatraServlet with FileUploadSupport {
error {
case e: SizeConstraintExceededException => "Oh, too much! Can't take it all."
case e: IOException => "Server denied me my meal, thanks anyway."
}
post("/eatfile") {
"Thanks! You just provided me " + fileParams("lunch").size + " bytes for a lunch."
}
}
}}* @note Once any handler with FileUploadSupport has accessed the request, the fileParams returned by FileUploadSupport will remain fixed for the lifetime of the request.
Attributes
- Note
-
Will not work on Jetty versions prior to 8.1.3. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=376324. The old scalatra-fileupload module still works for earlier versions of Jetty.
- Companion
- object
- Supertypes
-
trait HasMultipartConfigtrait ServletBasetrait ScalatraBasetrait TypeConverterSupporttrait ScalatraParamsImplicitstrait Initializabletrait DynamicScopetrait RequestResponseScopetrait CoreDsltrait Controltrait Handlertrait ScalatraContexttrait CookieContexttrait SessionSupporttrait ServletApiImplicitsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
FileUploadSupport.type
Read-only immutable wrapper for an HttpServletRequest that can, for the most part, be passed around to different threads.
Read-only immutable wrapper for an HttpServletRequest that can, for the most part, be passed around to different threads.
This is necessary because ServletContainers will "recycle" a request once the original HTTP thread is returned, meaning that a lot of attributes are set to null (in the case of Jetty).
Limitations of this class include the following:
- it is mostly immutable (methods on the original request are not given stable values, nor are methods that return non-primitive types)
- changes made to the original object or this object may not be reflected across threads
Value parameters
- originalRequest
-
the original HttpServletRequest to wrap
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass HttpServletRequestWrappertrait HttpServletRequestclass ServletRequestWrappertrait ServletRequestclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
RichRequest.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait AttributesMapclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Extension methods to the standard ServletContext.
Extension methods to the standard ServletContext.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait AttributesMapclass Objecttrait Matchableclass AnyShow all
Extension methods to the standard HttpSession.
Extension methods to the standard HttpSession.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait AttributesMapclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- object
- Supertypes
-
trait ServletContextListenertrait EventListenerclass Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ScalatraListener.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object ServletApiImplicits.typetrait CoreDsltrait ScalatraBasetrait ServletBasetrait AsyncSupporttrait FutureSupporttrait FileUploadSupporttrait ScalatraFiltertrait ScalatraServlettrait RequestLoggingtrait ApiFormatstrait LifeCycletrait MethodOverridetrait ScalatraContextclass AsyncResulttrait SslRequirementclass SweetCookiesShow all
Attributes
- Companion
- trait
- Supertypes
- Self type
-
ServletApiImplicits.type
ServletBase implements the Scalatra DSL with the Servlet API, and can be a base trait of a Servlet or a Filter.
ServletBase implements the Scalatra DSL with the Servlet API, and can be a base trait of a Servlet or a Filter.
Attributes
- Supertypes
-
trait ScalatraBasetrait TypeConverterSupporttrait ScalatraParamsImplicitstrait Initializabletrait DynamicScopetrait RequestResponseScopetrait CoreDsltrait Controltrait Handlertrait ScalatraContexttrait CookieContexttrait SessionSupporttrait ServletApiImplicitsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait AsyncSupporttrait FutureSupporttrait FileUploadSupporttrait ScalatraFiltertrait ScalatraServlet
Attributes
- Supertypes
-
class Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all