• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts error

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what caused this error,I have rewrote my struts-config.xml.

org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found.

My struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>

<struts-config>

<form-beans>
<form-bean name="messageFormBean"
type="test.MessageFormBean"/>
</form-bean>

<action
path="/messageLogin"
type="test.MessageActionClass"
name="messageFormBean"
scope="request"
<forward name="path"
path="/WEB-INF/view/messageSuccess.jsp"/>
</action>

<message-resources parameter="MessageResources" />
<message-resources parameter="TestMessageResources"
null="false" />

</struts-config>


My JSP

<%@ taglib uri="http://struts.apache.org/tags-bean"
prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html"
prefix="html" %>
<html>
<head>
<Title> Login </title>
</head>
<body>
<Center>
<html:form action="/messageLogin">
<bean:message key="form.firstName" /> :
<html:text property="firstName"/><br>
<bean:message key="form.lastName" /> :
<html:text property="lastName"/><br>
<bean:message key="form.emailID" /> :
<html:text property="emailID"/><br>
<html:submit>
Submit
</html:submit>
</html:form>
</center>
</body>
</html>
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a slight change in 'My struts-config.xml'. sorry, <action-mappings> is missing in 'My struts-config.xml' in the above question. But <action-mappings> is present in my origianl struts-config.xml. so that may not have caused the error. so what caused the error?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can see at least two errors: There is no closing </form-beans> tag. Also, at least one of your <message-resources> stanzas must have a key attribute. Also check out question 10 in the JavaRanch Struts FAQ.

Thanks for being up front about the fact that your post didn't accurately represent what's in your config file. However, this brings up a "pet peeve" of mine, so forgive while I unload a little.

For a person trying to be helpful, having spent some time searching through a post for some minute detail that might be the cause of someone's problem, then finally finding something and pointing it out, there's nothing more irritating than being told "Oh, yeah, I just copied it wrong into my post. That's not the problem. Can you help me find the real problem?"

If you're going to ask other developers to spend their time looking for problems in your code, don't you think you at least owe them the courtesy of taking the time to make sure the code you put in your post accurately represents the code that's causing you the problem?
[ March 11, 2007: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>><html:form action="/messageLogin">

also in above tag, you might want to include what method you want to call in the servlet :get or post.

if its get
<html:form action="/messageLogin" method="get">

if its post
<html:form action="/messageLogin" method="post">

post is most commonly used.
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry Merrill, I would take utmost care, not to repeat that mistake again. By the way, what did you mean by this:

'Also, at least one of your <message-resources> stanzas must have a key attribute.'

and what does DTD stands for?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot have two <message-resources> tags in the same struts-config file unless one of them is defined by a key attribute. Example:

In the above example, "MessageResources" is the default message resource, and the "TestMessageResources" is a secondary resource. In order to reference a secondary resource, you must specify a bundle attribute. So, for example, if I want to reference a message in the "TestMessageResources", I would specify the following:

For more detailed information on this, see this link.

what does DTD stand for?


A DTD (Data Type Definition) is the governing document for an XML file. It declares the rules for what elements can be in the XML file, their frequency, and the order in which they appear. If your Struts-config.xml file does not conform to the rules in the DTD file declared at the top of the document, Struts will throw an exception stating that it cannot parse the XML file.
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could you please tell me where the DTD file and all the declarations are.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the beginning of your struts-config.xml file, you should have a declaration that looks like this:

The last line of this declaration is a real URI that points to the location of the DTD. You can use your browser to download it. The DTD declared is dependent on the version of Struts you're using. If you're using version 1.2.x, then the DTD will be different. Since I'm using 1.3.8, the DTD is declared as version 1.3.

Here's a tip: I almost never create a struts-config.xml file from scratch. I'd recommend that you unzip the struts-blank.war file that came with the download and copy the struts-config.xml file found in that application into your application and use it as a template for your config file.
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic