Package com.logicaldoc.webservice
Class WebserviceServletUtil
java.lang.Object
com.logicaldoc.webservice.WebserviceServletUtil
Some methods useful in webservice servlets
- Since:
- 8.7
- Author:
- Marco Meschieri - LogicalDOC
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
downloadFile
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, File file, String fileName) Sends the specified file to the response object; the client will receive it as a download Sends the specified file to the response object; the client will receive it as a downloadstatic void
setContentDisposition
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String filename) Sets the correct Content-Disposition header into the responsestatic Session
validateSession
(String sid) Throws a runtime exception id the given session is invalidstatic Session
validateSession
(javax.servlet.http.HttpServletRequest request)
-
Method Details
-
setContentDisposition
public static void setContentDisposition(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String filename) throws UnsupportedEncodingException Sets the correct Content-Disposition header into the response- Parameters:
request
- the HTTP requestresponse
- the server's responsefilename
- name of the file- Throws:
UnsupportedEncodingException
- error trying to encode the response
-
downloadFile
public static void downloadFile(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, File file, String fileName) throws FileNotFoundException, IOException, javax.servlet.ServletException Sends the specified file to the response object; the client will receive it as a download Sends the specified file to the response object; the client will receive it as a download- Parameters:
request
- the current requestresponse
- the file is written to this objectfile
- file to servefileName
- client file name- Throws:
FileNotFoundException
- cannot find the file to downloadIOException
- generic I/O errorjavax.servlet.ServletException
- error in the servlet container
-
validateSession
public static Session validateSession(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException - Throws:
javax.servlet.ServletException
-
validateSession
Throws a runtime exception id the given session is invalid- Parameters:
sid
- identifier of the session- Returns:
- the session
- Throws:
javax.servlet.ServletException
- the session does not exist or is expired
-