我在AWS中部署了Java Web应用程序,并尝试访问时出现了下面提到的错误。我没有使用xml文件,因为jsp会调用servlet类。
我的index.jsp
代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<meta name=”viewport” content=”width=device-width,height=device-height initial-scale=1.0″/>
<link rel="stylesheet" href="style.css">
<form autocomplete='off' class='form' action="scrap" method="post">
<div class='control'>
<h1>
Please fill details
</h1>
</div>
<div class='control block-cube block-input'>
<input name='Product link' placeholder='Product link' type='text'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
</div>
<div class='control block-cube block-input'>
<input name='Email address' placeholder='Email address' type='text'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
</div>
<button class='btn block-cube block-cube-hover' type='sumbit'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
<div class='text'>
Save
</div>
</button>
<div class='credits'>
</div>
</form>
</html>
我的servlet代码
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<meta name=”viewport” content=”width=device-width,height=device-height initial-scale=1.0″/>
<link rel="stylesheet" href="style.css">
<form autocomplete='off' class='form' action="scrap" method="post">
<div class='control'>
<h1>
Please fill details
</h1>
</div>
<div class='control block-cube block-input'>
<input name='Product link' placeholder='Product link' type='text'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
</div>
<div class='control block-cube block-input'>
<input name='Email address' placeholder='Email address' type='text'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
</div>
<button class='btn block-cube block-cube-hover' type='sumbit'>
<div class='bg-top'>
<div class='bg-inner'></div>
</div>
<div class='bg-right'>
<div class='bg-inner'></div>
</div>
<div class='bg'>
<div class='bg-inner'></div>
</div>
<div class='text'>
Save
</div>
</button>
<div class='credits'>
</div>
</form>
</html>
java.lang.UnsupportedClassVersionError的原因是编译时JDK较高而运行时JDK较低。>
@WebServlet(name="/scrap",urlPatterns={"/scrap"})
public class scrap extends HttpServlet {
static String start="start";
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String link = request.getParameter("Product link");
String email = request.getParameter("Email address");
//response.setContentType("text/html");
PrintWriter out = response.getWriter();
if(start.contentEquals("start"))
{
start="notsatrt";
Thread newthread = new Thread(new test());
newthread.start();
}
database testing=new database(link,email);
testing.verification();
testing.run();
request.setAttribute("verifyemail",email);
request.getRequestDispatcher("/before.jsp").forward(request,response);
out.close();
}
public void destroy() {
// do nothing.
}
}