I am comparing the two string in the IF block and both of the strings are not null but a really weird error is being shown. Even though this same code is working with using simply servlets. But when I run this code in JSP it gives the error. I have already checked if the values were null but the output is exactly what was input in the form. My code is this
<%
String sender = (String) request.getAttribute("sender");
System.out.println(request.getParameter("data") + " " + request.getParameter("sender"));
String process = "process";
if (sender.equals(process)) {
String itemName = request.getParameter("data");
%>
<%="No Item with name: " + itemName + " Found"%>
<%
}
%>
This is the error that is being shown.
Some Error: An exception occurred processing [/error.jsp] at line [31] 28: String sender = (String) request.getAttribute("sender"); 29: System.out.println(request.getParameter("data") + " " + request.getParameter("sender")); 30: String process = "process"; 31: if (sender.equals(process)) { 32: 33: String itemName = request.getParameter("data"); 34: %> Stacktrace: org.apache.jasper.JasperException: An exception occurred processing [/error.jsp] at line [31] 28: String sender = (String) request.getAttribute("sender"); 29: System.out.println(request.getParameter("data") + " " + request.getParameter("sender")); 30: String process = "process"; 31: if (sender.equals(process)) { 32: 33: String itemName = request.getParameter("data"); 34: %> Stacktrace: [Ljava.lang.StackTraceElement;@6fb251a5
Folllowing is my complete page code
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>No Data</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<meta name="theme-color" content="#fafafa">
</head>
<body>
<section id="google-form" class="section google-form">
<div class="account_create-text center ">
<h4>Oops No data found. </h4>
</div>
<br>
<span class="username_curr-email blue ce block spacer-10">!
<%
String sender = (String) request.getAttribute("sender");
System.out.println(request.getParameter("data") + " " + request.getParameter("sender"));
String process = "process";
if (sender.equals(process)) {
String itemName = request.getParameter("data");
%>
<%="No Item with name: " + itemName + " Found"%>
<%
}
%>
</span>
<span class="spacer-10 block"></span>
<span class="spacer-10 block"></span>
<span class="spacer-10 block"></span>
<br>
<br>
<br>
<div class="bb-30 spacer-10">
<a href="Task1.html" style="text-decoration: none;" class="button-elevated ">
Go back
</a>
</div>
<br>
<br>
</section>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…