mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support weblogic websocket and weblogic 15.1.1.0
This commit is contained in:
@@ -14,6 +14,8 @@ dependencies {
|
||||
implementation("commons-fileupload:commons-fileupload:1.5")
|
||||
implementation("commons-beanutils:commons-beanutils:1.9.3")
|
||||
providedCompile("jakarta.servlet:jakarta.servlet-api:5.0.0")
|
||||
providedCompile("jakarta.websocket:jakarta.websocket-api:2.2.0")
|
||||
providedCompile(libs.jakarta.websocket.client.api)
|
||||
testImplementation(libs.junit.jupiter)
|
||||
testRuntimeOnly(libs.junit.platform.launcher)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import jakarta.websocket.*;
|
||||
import jakarta.websocket.server.ServerEndpoint;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ServerEndpoint("/ws/demo")
|
||||
public class EmptyWebSocketEndpoint {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EmptyWebSocketEndpoint.class.getName());
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session) {
|
||||
logger.info("New connection established: " + session.getId());
|
||||
try {
|
||||
// 向客户端发送欢迎消息
|
||||
session.getBasicRemote().sendText("Connected successfully! Session ID: " + session.getId());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) {
|
||||
logger.info("Received message from " + session.getId() + ": " + message);
|
||||
try {
|
||||
session.getBasicRemote().sendText("Server Echo: " + message);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session, CloseReason closeReason) {
|
||||
logger.info("Session closed: " + session.getId() + ", Reason: " + closeReason.getReasonPhrase());
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable throwable) {
|
||||
logger.severe("Error on session " + (session != null ? session.getId() : "null") + ": " + throwable.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,19 @@ public class UploadServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
Part file = request.getPart("file");
|
||||
String fileName = getFileName(file);
|
||||
String uploadPath = getServletContext().getRealPath(UPLOAD_DIRECTORY) + File.separator + fileName;
|
||||
String uploadFolder = getServletContext().getRealPath(UPLOAD_DIRECTORY);
|
||||
if (uploadFolder == null) {
|
||||
// weblogic
|
||||
File tempDir = (File) getServletContext().getAttribute("jakarta.servlet.context.tempdir");
|
||||
if (tempDir == null) {
|
||||
tempDir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir");
|
||||
}
|
||||
uploadFolder = tempDir.getParent() + File.separator + "war";
|
||||
}
|
||||
if (!uploadFolder.endsWith(File.separator)) {
|
||||
uploadFolder += File.separator;
|
||||
}
|
||||
String uploadPath = uploadFolder + fileName;
|
||||
InputStream inputStream = file.getInputStream();
|
||||
File uploadFile = new File(uploadPath);
|
||||
IOUtils.copy(inputStream, Files.newOutputStream(uploadFile.toPath()));
|
||||
|
||||
@@ -13,7 +13,7 @@ java {
|
||||
dependencies {
|
||||
implementation("commons-fileupload:commons-fileupload:1.3.3")
|
||||
implementation("commons-beanutils:commons-beanutils:1.9.2")
|
||||
implementation("javax.websocket:javax.websocket-api:1.1")
|
||||
providedCompile("javax.websocket:javax.websocket-api:1.1")
|
||||
providedCompile("javax.servlet:servlet-api:2.5")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
id="WebApp_ID" version="2.5">
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
id="WebApp_ID" version="3.0">
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
Reference in New Issue
Block a user