📄 index.jsp
字号:
<%@ page language="java" import="java.util.*,java.io.*,org.apache.commons.httpclient.HttpClient,java.net.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName()
+ ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
URL myURL = null;
HttpURLConnection conn = null;
BufferedReader reader = null;
String urlString="http://localhost:7080/pnews/MyJsp.jsp";
try {
myURL = new URL(urlString); // urlString defined elsewhere
conn=(HttpURLConnection) myURL.openConnection();
//conn = new HttpURLConnection(myURL);
//new HttpURLConnection()
conn.connect();
// String temp=conn.getRequestProperty("key");
// out.println(temp);
out.println("conn.getAllowUserInteraction()"+ conn.getAllowUserInteraction());
out.println("conn.getRequestMethod(): "+conn.getRequestMethod());
out.println("conn.getResponseMessage(): "+conn.getResponseMessage());
out.write("conn.getContext(): "+conn.getContent());
reader = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
// Do something with output...
//out.println(line + "\n");
}
reader.close();
reader = null;
} catch (Exception e) {
System.out.println(this.getClass().getName()
+ ": problem getting content from " + myURL.toString());
e.printStackTrace();
} finally {
conn.disconnect();
}
%>
<br>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -