新手jsp页面错误提示请教写了一个简单的代码,在本地的tomcat上运行是正常的,一放到服务器上就报错了。代码
新手jsp页面错误提示请教
写了一个简单的代码,在本地的tomcat上运行是正常的,一放到服务器上就报错了。
代码原文
Java code<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %><%@ page import="com.allinpay.api.internal.util.CryptoUtils"%><%@ page import="java.text.DateFormat"%><%@ page import="java.text.SimpleDateFormat"%><%@ page import="java.util.TimeZone"%><%@ page import="java.util.Date"%><% String DATE_TIME_FORMAT = "yyyyMMddHHmmss";String DATE_TIMEZONE = "GMT+8";String keyData = request.getParameter("keydata"); //= "123456";//Long timestamp = Long.parseLong(request.getParameter("timestamp")); //20120310123025L;Long timestamp = new java.util.Date().getTime();String dataSecret = "abcdefgh";String key = com.allinpay.api.internal.util.CryptoUtils.encryptKeyData(keyData,timestamp,dataSecret);DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);df.setTimeZone(TimeZone.getTimeZone(DATE_TIMEZONE));String timestamps = df.format(new Date(timestamp));//key = URLEncoder.encode(key, "UTF-8");out.print(key+" "+timestamps);%>
错误提示:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /apis.jsp at line 17
14: //Long timestamp = Long.parseLong(request.getParameter("timestamp")); //20120310123025L;
15: Long timestamp = new java.util.Date().getTime();
16: String dataSecret = "abcdefgh";
17: String key = com.allinpay.api.internal.util.CryptoUtils.encryptKeyData(keyData,timestamp,dataSecret);
18: DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
19: df.setTimeZone(TimeZone.getTimeZone(DATE_TIMEZONE));
20: String timestamps = df.format(new Date(timestamp));
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/allinpay/api/internal/util/CryptoUtils
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.apis_jsp._jspService(apis_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.UnsupportedClassVersionError: com/allinpay/api/internal/util/CryptoUtils
org.apache.jsp.apis_jsp._jspService(apis_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.26 logs.
编译的class文件是放在ROOT/WEB_INF/classes目录下的
[解决办法]
<%
String DATE_TIME_FORMAT = "yyyyMMddHHmmss";
String DATE_TIMEZONE = "GMT+8";
String keyData = request.getParameter("keydata"); //= "123456";
//Long timestamp = Long.parseLong(request.getParameter("timestamp")); //20120310123025L;
Long timestamp = new java.util.Date().getTime();
String dataSecret = "abcdefgh";
String key = com.allinpay.api.internal.util.CryptoUtils.encryptKeyData(keyData,timestamp,dataSecret);
DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
df.setTimeZone(TimeZone.getTimeZone(DATE_TIMEZONE));
String timestamps = df.format(new Date(timestamp));
//key = URLEncoder.encode(key, "UTF-8");
out.print(key+" "+timestamps);
%>
把这些代码放到后台main函数里面执行一下 看能否正常运行
然后断点调试
[解决办法]
不要直接把class考出来。。
将root下的都删了。然后从eclipse导出到war,放到root下,启动tomcat,让tomcat自己编译
[解决办法]
war放到webapps下
[解决办法]
你是怎么导到 tomcat 里面的?
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html