wood burning stoves 2.0*
The moose likes Struts and the fly likes For Struts developers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "For Struts developers" Watch "For Struts developers" New topic
Author

For Struts developers

Nirodhaa Jaymenine
Greenhorn

Joined: Oct 14, 2008
Posts: 3
I am new to Struts and I am getting following exception when I try to run a very simple program.
Please help me to resolve this issue, It will be a great help.

Thanks


I am using Struts 1.1 and Tomcat 5.0.14.

-----------------index.jsp-------------------------
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<head>
<html:base/>
</head>
<body>
<html:link page="/CustomerDetails.jsp">Customer Form</html:link>
</body>
</html:html>

----------------------struts-config.xml------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="CustomerForm" type="mybank.app1.CustomerForm"/>
</form-beans>
<global-forwards>
<forward name="mainpage" path="index.jsp"/>
</global-forwards>
<action-mappings>
<action path="/submitCustomerForm" type="mybank.app1.CustomerAction" name="CustomerForm" scope="request" validate="true" input="CustomerDetails.jsp">
<forward name="success" path="Success.jsp"/>
<forward name="failure" path="Failure.jsp"/>
</action>
</action-mappings>
<controller processorClass="org.apache.struts.action.RequestProcessor"/>
<message-resources parameter="mybank.app1.App1Messages"/>
</struts-config>



-----------Exception-----------------------
java.lang.NullPointerException
org.apache.struts.util.RequestUtils.pageURL(RequestUtils.java:1596)
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:541)
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:436)
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:495)
org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:353)
org.apache.jsp.index_jsp._jspx_meth_html_link_0(index_jsp.java:138)
org.apache.jsp.index_jsp._jspx_meth_html_html_0(index_jsp.java:100)
org.apache.jsp.index_jsp._jspService(index_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Nirodhaa Jaymenine
Greenhorn

Joined: Oct 14, 2008
Posts: 3
Please look into this and help me. It would be a great help.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
What is the url you used to access the page? The error makes it seem like it can't figure out what the rest of the url should be for you link, and I assume that comes from the request.
Nirodhaa Jaymenine
Greenhorn

Joined: Oct 14, 2008
Posts: 3
Thanks for replying. request url is

There is a <http:link> tag there

http://localhost:8080/App1/index.jsp
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

"Nirodhaa", please check your private messages for an important administrative message.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Ok, I did a little digging, and I think your problem is that the html:link tag requires some parameters exist in the request object that are put there by your servlet. Since you accessed this jsp directly with out going through the servlet (I'm assuming that your servlet isn't set up to process .jsp request) the link tag crashes.

I think your options are to either create your link with out the html tag, or to set up a dummy action who's form and action class don't do anything and then forward to the jsp.
 
jQuery in Action, 2nd edition
 
subject: For Struts developers
 
Similar Threads
MalformedURLException
java.lang.ClassNotFoundException: org.apachi.struts.action.ActionServlet
Null Pointer in RequestUtils.
Cannot find message resources
html:link forward problem.