-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jwhich.jsp
74 lines (69 loc) · 3.02 KB
/
Jwhich.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page session="true" %>
<%
request.setCharacterEncoding("UTF-8");
String className = request.getParameter("classname");
if(className == null || className.length() == 0)
{
%>
<html>
<body onLoad='javascript:document.theform.classname.focus()'>
<h3>JAVA Class/Resource Locating Information</h3>
<form name='theform' method='POST' action='Jwhich.jsp'>
Class/resource name specified has extension? <input title="" type='radio' name='has-extension' value='true'>true <input title="" type='radio' name='has-extension' value='false' checked='checked'>false<br>
Enter name of class/resource to locate: <input title="" type='text' name='classname'><br>
</form>
</body>
</html>
<%
return;
}
String save_classname = className;
String strhasext = request.getParameter("has-extension");
boolean hasext = false;
if("true".equalsIgnoreCase(strhasext))
hasext = true;
if(!className.startsWith("/"))
className = "/" + className;
className = className.replace('.', '/');
if(!hasext)
className += ".class";
else
{
int pos = className.lastIndexOf('/');
if(pos != -1)
className = className.substring(0, pos) + '.' + className.substring(pos+1);
}
java.net.URL classUrl = getClass().getResource(className);
%>
<h3>JAVA Class/Resource Locating Result</h3>
<%
if(classUrl == null)
out.println("Class or resource '<font color=red>" + className + "</font>' <strong>not found</strong> in CLASSPATH.");
else
{
%>
<menu>
<%
out.println("<li>Class or resource '<font color=red>" + className + "</font>' found in \n'<font color=blue>" + classUrl.getFile() + "</font>'");
if(className.endsWith(".class"))
{
%>
<br/><br><br>
<%
className = save_classname.replace('/', '.');
if(className.indexOf(".class") != -1)
className = className.substring(0, className.indexOf(".class"));
Class cls = Class.forName(className);
ClassLoader cl = cls.getClassLoader();
if(cl != null)
{
out.println("<li>" + cls.getName() + " has been loaded by ");
out.println(cl.getClass().getName() + " <font color='gray'>" + cl + "</font>");
}
}
%>
</menu>
<%
}
%>