• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.apache.jasper.JasperException: An exception occurred processing JSP page

 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I'm new to Struts and was doing a tutorial for connecting to a MySQL Database.

My problem is that the first jsp won't work.

Here's the code aswell as the error message:

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts 2 Insert Data Application!</title>

<link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>

</head>
<body>

<s:form action="insertData" method="POST" validate="true">

<tr>
<td colspan="2">
Please enter
</td>
</tr>

<s:actionerror />
<s:fielderror />

<s:textfield name="username" label="User Name"/>
<s:password name="password" label="Password"/>
<s:submit value="Save" align="center"/>

</s:form>
</body>
</html>


The error I get is:

org.apache.jasper.JasperException: An exception occurred processing JSP page /pages/insertData.jsp at line 6

3: <head>
4: <title>Struts 2 Insert Data Application!</title>
5:
6: <link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>
7:
8: </head>
9: <body>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NullPointerException
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:54)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
org.apache.jsp.pages.insertData_jsp._jspx_meth_s_005furl_005f0(insertData_jsp.java:118)
org.apache.jsp.pages.insertData_jsp._jspService(insertData_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I understand that something is wrong with either the "<link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>" command or perhaps with the main.css itself?
Yes, the main.css is in the css folder. -smiles-

Any tips on how to fix it are highly appreciated!
Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please put your code in code tags; it's much, much easier to read.

It appears as though you're not accessing the page through an action, but instead directly accessing the URL. The use of S2 custom tags implies the presence of a value stack, which implies that they'll always be accessed through an action.

This is good design anyway; exposing JSP pages/fragments directly to users is not usually recommended when using a web app framework.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that, I'm new to forums aswell -smiles-

I managed to fix the problem with some help from a friend.
He told me to put a filtermapping in the web.xml, and it worked.

Thank you very much for your help anyway!
 
Ravi Jagtap
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alia,

I am getting the same error, could you please tell how you solved the problem and for how you added the filtermapping in web.xml


Thanks
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was a while ago, but here's a copy of my web.xml


Only works with struts2-core-2.1.3.jar or newer (I use Struts2-core-2.1.6.jar)

I hope it helps.
Alia
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FYI, that filter is deprecated in Struts 2.1.3+; see here.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, thank you, I didn't know that.
I've now changed my filter and updated the previously posted code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic