Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 1.beginner, code not working

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner , just read a book of struts and tried my first app on it. can anyone tell what is the problem with my code . it gives an error at line 7 :

<html:form action="/starFinder" >


my index.jsp is :

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>



am i using the wrong tag ?? or is it something else??
 
M Turner
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your struts.xml have an action mapping for "/starFinder"? If not, your page will bomb.
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my struts-config.xml is as follows : yes it has the mapping


 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone please help me out? I am stuck at the first step ?
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a little modification:

my index.jsp is:




my struts-config.jsp is :



now i m getting the following exception:

org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NullPointerException: Module 'null' not found.
org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755)
org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:735)
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:818)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:488)
org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:97)
org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



am using struts 1.3 tomcat6.0.24
please help me out.i m stuck at my first trial app.
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you accessing the JSP page directly?
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I typed the following link :

http://localhost:9000/ch03app

and my index.jsp is in the ch03app directory.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pages with Struts tags shouldn't be accessed directly; the tags won't work. In general, there shouldn't be any JSP pages accessed directly in an MVC-based app.
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please tell me how can i fix that? my index.jsp is :



web.xml is:



struts-config.xml is :



please tell me how can i prevent in index.jsp from accessing directly?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't type into the browser.

JSP pages should be under WEB-INF to disallow direct access. JSP pages with Struts 1 form tags must go through an action: configure an action for the input page somehow.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic