File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: cannot be resolved in either web.xml or the jar files deployed with this application

What is the problem.?

Anil Deshpande
SCJP 1.5, SCWCD 1.5
Sushil Jamsandekar

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

Joined: Aug 03, 2008
Posts: 9326

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="". The correct one is -uri=""

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/" 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 -





BeerSelectionForm .java

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

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.
I agree. Here's the link:
subject: strange error with respect to web.xml file