How can I get real system file path from WebSocket endpoint
While I'm in the context of a servlet, I can easily get the real path to the system file by calling request.getServletContext (). getRealPath (UPLOAD_PATH). Please be friends how can I make an equivalent from a WebSocket endpoint in Java EE 7. Thanks in advance.
You can get path information from ServerEndpointConfig # getPath () . The only difference between the results of this method ServletContext#getRealPath()
is that it gives a relational path; you can simply prefix the results of this method with the name of the context root. To get results you need to implement onOpen
(from class javax.websocket.Endpoint
)
//called when the client first negotiates the opening of the websocket connection
public void onOpen(Session session, ServerEndpointConfig config){
String path = config.getPath();
}