我试图在当前的JSP页面中调用另一个JSP页面。基本上在我的editUrl.jsp
中,我也想包括genurl.jsp
。
据我所知,实现方法之一是:
<jsp:include page="file.jsp" />
或
<%@ include file="filename" %>
所以我遵循了该方法,并按如下所示进行了操作:
<%@ include file="genurl.jsp" %>
当我运行程序时,它将引发nullpointer异常,这意味着它无法找到该文件。我检查了我的根文件夹,它们都位于同一文件夹中。这是供参考的屏幕截图。
我做错什么了吗?
我的genurl.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../../../WEB-INF/jspf/mcre.jspf" %>
<%@include file="../../../WEB-INF/jspf/session.jspf"%>
<%@ page import="com.htasia.panton9.Core.Settings.SettingsFacadeLocal" %>
<%@page import="com.htasia.panton9.Utilities.CoreUtil,
com.htasia.MCRE.File.*,
com.htasia.MCRE.Types.*,
com.htasia.panton9.Core.Node.*,
com.htasia.panton9.Entities.Core.Node,
com.htasia.panton9.Entities.MCRE.*"%>
<%@ page import="javax.persistence.EntityManager" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
<%@ page import="java.security.SecureRandom" %>
<%@ page import="java.math.BigInteger" %>
<html>
<%
String relPath = "../../../";
NodeFacadeLocal nFacade = null;
InitialContext ntx = new InitialContext();
try {
nFacade = (NodeFacadeLocal) ntx.lookup("java:comp/env/node");
} catch (NamingException e) {
e.printStackTrace();
}
%>
<head>
<script type="text/javascript" src="<%=relPath%>js/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<%=relPath%>js/jquery/jquery-panton-win.js"></script>
<script type="text/javascript" src="<%=relPath%>js/jquery/jquery-panton-win-2.js"></script>
<title>Generate URL</title>
</head>
<body>
<div id="table123" style="overflow:scroll;height:400px;width:100%;overflow:auto">
<table class="filesTbl">
<tr>
<th width="1%">
Checkbox
</th>
<th width="1%">
No
</th>
<th width="20%">
File Name
</th>
<th width="50%">
Unique URL
</th>
<th width="1%">
Edit
</th>
<th width="1%">
Copy
</th>
<th width="1%">
Email
</th>
</tr>
<%
//need to input logic to populate data on each row
int counter=0;
int tally=0;
String[] split = request.getParameter("nodeID").split(",",0);
for(int i=0;i<split.length;i++){
long file=Long.parseLong(split[i]);
List files = fileFacade.list_items(file);
for (Iterator rstltr = files.iterator(); rstltr.hasNext();) {
Fmedia fv = (Fmedia) rstltr.next();
Node nd = nodeFacade.get(fv.getNodeid(), false);
// Fmedia fm = fileFacade.get_file(fv.getNodeid());
int count = 0;
count++;
long fileid= nd.getNodeid();
SettingsFacadeLocal settingFacade = (SettingsFacadeLocal)ctx.lookup("java:comp/env/settings");
String redirectURL = settingFacade.get("SERVER_URL").getAtval();
//declare a timestamp for unique URL
// String timeStamp=new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new java.util.Date());
// String hash = org.apache.commons.codec.digest.DigestUtils.sha256Hex(timeStamp);
SecureRandom secureRandom=new SecureRandom();
byte[] token = new byte[12];
secureRandom.nextBytes(token);
String hash= new BigInteger(1, token).toString(12);
%>
<tbody>
<tr>
<td width="5%">
<script>
// function to copy multiple URL links
function copymultiplelink() {
var selectedFiles = $('.fileCheck:checked');
if(selectedFiles.length < 1 ){
alert("Please select at least one file.");
return false;
}
var filesList = [];
var $fileChecks = $('.fileCheck:checked');
$fileChecks.each(function() {
filesList.push($(this).val());
});
alert("You have copied " + filesList.length+ " URL");
copyURL(filesList.join("\n"),false);
}
//function to call the edit the page
function editURL(filename,url){
var x=document.getElementById("table123");
x.style.display="none";
$('body').pWin("open", {
x: 260,
y: 47,
height: 450,
width: 881,
title: "Edit:Advance Configuration",
skinMode:'dialog',
iframe:true,
url: "editUrl.jsp",
data: {
filename:filename,
link:url
},
offResize:true,
offMove:true,
onTitle:false,
offBottom:true
});
// x.style.display="none";
}
</script>
<!--Display Checkbox -->
<input type="checkbox" class="fileCheck" id="<%=tally=tally+1%>" value="<%=redirectURL+"/repository/file/view/viewPDF.jsp?f0="+nd.getNodeid()+"&ts="+hash%>" />
</td>
<td>
<!--Display No -->
<% counter=counter+1;
out.print(counter);
%>
</td>
<td width="28%">
<!-- Display Filename -->
<%=nd.getNodedesc()%>
</td>
<td width="100%">
<!-- Display Unique URL -->
<%=redirectURL+"/repository/file/view/viewPDF.jsp?f0="+nd.getNodeid()+"&ts="+hash%>
<%
fileFacade.insert_url(nd.getNodeid(),"f0="+nd.getNodeid()+"&ts="+hash);
//fileFacade.insert_url(nd.getNodeid(),"{syscont url}/repository/file/view/viewPDF.jsp?{url});
%>
</td>
<td>
<!-- Display EDIT/DEL -->
<input type="button" value="Edit URL" onclick="editURL('<%=nd.getNodedesc()%>','<%=redirectURL+"/repository/file/view/viewPDF.jsp?f0="+nd.getNodeid()+"&ts="+hash%>')" >
</td>
<td> <!-- Display COPY feature -->
<input type="button" value="Copy URL" onclick="copyURL('<%=redirectURL+"/repository/file/view/viewPDF.jsp?f0="+nd.getNodeid()+"&ts="+hash%>',true)">
</td>
</tr>
</tbody>
<%}}
%>
<script>
function copyURL(url,showMsg) {
var copyText = url;
var el = document.createElement('textarea');
el.value = copyText;
el.setAttribute('readonly', '');
el.style = {
position: 'absolute',
left: '-9999px'
};
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
if(showMsg==true) {
alert("You have copied the URL");
}
}
</script>
</table>
<!--Copy button to copy multiple links -->
<div class="wrapper">
<button type="button" onclick="copymultiplelink()"> Copy Selected URL</button>
</div>
</div>
<style>
.wrapper {
position: absolute;
top: 90%;
left: 5%;
}
</style>
</body>
</html>
编辑:
完整异常跟踪:
[2019-03-25T13:17:18.792+0800] [glassfish 4.1] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=30 _ThreadName=http-listener-1(4)] [timeMillis: 1553491038792] [levelValue: 900] [[
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.repository.file.url.editUrl_jsp._jspService(editUrl_jsp.java:349)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:722)
]]
[2019-03-25T13:48:44.442+0800] [glassfish 4.1] [INFO] [] [javax.enterprise.web.core] [tid: _ThreadID=185 _ThreadName=ContainerBackgroundProcessor[StandardEngine[glassfish-web].StandardHost[server].StandardContext[]]] [timeMillis: 1553492924442] [levelValue: 800] [[
Session event listener threw exception
java.lang.NullPointerException
at org.jboss.weld.servlet.WeldTerminalListener.getSessionContext(WeldTerminalListener.java:72)
at org.jboss.weld.servlet.WeldTerminalListener.sessionDestroyed(WeldTerminalListener.java:64)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:910)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:854)
at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:771)
at org.apache.catalina.session.StandardManager.processExpires(StandardManager.java:1056)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:6371)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1823)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1812)
at java.lang.Thread.run(Thread.java:722)
]]