aspose file tools*
The moose likes Struts and the fly likes strange error with respect to web.xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "strange error with respect to web.xml file" Watch "strange error with respect to web.xml file" New topic
Author

strange error with respect to web.xml file

Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
I am preparing for SCWCD, I am implementing the struts application as shown in the Heas First Servlets and JSP.


form.jsp looks like:




web.xml looks like




the ActionForm looks line:



and the BeerSelectionForm




the code for web.xml is:



the struts-config.xml is



When I execute and access the form.jsp, it gives me the error


org.apache.jasper.JasperException: The absolute uri: http://jakarta.apache.org/struts/tags-html cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:317)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:435)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:504)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1568)
org.apache.jasper.compiler.Parser.parse(Parser.java:132)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)



What is the problem.?


Anil Deshpande
SCJP 1.5, SCWCD 1.5
Sushil Jamsandekar
Greenhorn

Joined: Aug 11, 2008
Posts: 14
In your web.xml try putting following elements inside <servlet></servlet>



Also you need to download the taglib : struts-html.tld and make its refarance in web.xml like


Am not sure if we can referance the tld directly with the uri you have provided.


SCJP 1.4
Preparing for SCWCD
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

There's no need to map the tld in the web.xml. The container (or at least most containers) automatically search for tlds inside jar files inside the lib folder, so if the struts library files are in the lib folder, then the container will automatically map the URI to the tld...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
I changed the form.jsp

Now the code looks like this



But there seems to be problem with the struts-config.xml

It is givig me the error


is the problem with configuring FontController Servlet?
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

Hey Anil,

While trying the code, I discovered 5 errors that I had to resolve to get the code working. Those errors are as follows -

1- As I can see from your struts-config.xml you are using struts 1.3. The first mistake was in your form.jsp where you gave wrong uri="http://jakarta.apache.org/struts/tags-html". The correct one is -uri="http://struts.apache.org/tags-html"

2- In struts-config.xml , to represent action mapping you used opening tag <action-mapping> which is wrong, it should be <action-mappings>.

3- You gave the type in action as com.example.web.BeerSelection while your action class is BeerSelectionAction.

4- In form.jsp while submitting you selection action as "/select/SelectBeer.do" while there is no mapping in struts-config.xml for "/select/SelectBeer". I believe, you should have made only "/SelectBeer" as type in struts-config.xml.

5- In web.xml you had given servlet init parameter at completely wrong place. This comes under servlet tag

I corrected all those error at my end. Now it is working perfectly fine here. The corresponding code files are as attached below -

Form.jsp


Struts-config.xml




Web.xml



result.jsp



BeerSelectionAction.java



BeerSelectionForm .java



I hope, this would solve all your doubts and would give you a working example.

Regards
Salil Verma
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
Thanks for the comprehensive reply. I have not yet checked the code to verify it. But I am so happy with this replay I couldn't stop myself from replaying as a token of appreciation.

As soon as I will get time I will verify he code and respond with certain clarifications.

Thanks a lot
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
I did execute the code. And thanks once again. Did help me to clarify the mistakes.
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
Major problem, The code executes only when I am connected to the internet. If I am offline and start the tomcat it gives me this error



This is strange. Why should it be dependent on whether I am online or offline. I had executed Struts one year back. But it had executed even without I being connected to the internet.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: strange error with respect to web.xml file