File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Getting started with struts2 but having problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting started with struts2 but having problems" Watch "Getting started with struts2 but having problems" New topic
Author

Getting started with struts2 but having problems

Timo Tamme
Greenhorn

Joined: Nov 10, 2011
Posts: 8
I'm trying to setup maven and struts 2 project in Eclipse, but I'm having problems. I have chosen to create simple HelloWorld example and afterwards add some other functionality, but I'm having problems.

I have 'struts.xml' path in project: src/main/resources/struts.xml

and inside it:


also I have web.xml with path src/main/web/WEB-INF/web.xml and content:


From commandline I use 'mvn clean install' and I get .war file to target folder, that .war file I'm going to deploy under Tomcat (also it deploys it successfully) but when I enter url I get error:

The requested resource (/ContactWeb/Pages/Login.jsp) is not available.

same error with different url-s only path is different (/ContactWeb/Login.jsp, /ContactWeb/Login.action etc.).

In my project I do have Login.jsp, Index.jsp and also Welcome.jsp. They are under: src/main/web/Pages

I have read somewhere that in struts2 I need to but .action extension to url, but it doesn't work and also why in struts.xml is package name and namespace? what exactly needs to be there? I have read that is for page what it is going to display?
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Hi @Timo

I would like to add my analysis

The requested resource (/ContactWeb/Pages/Login.jsp) is not available.

it's 404 exception - Let us know how you are calling your action Login.

It should be
it should be http://localhost:8080/yourApplicationName/Login Remember in struts2 you can define any extension you want but if you are not specifying anything struts add .action

same error with different url-s only path is different (/ContactWeb/Login.jsp, /ContactWeb/Login.action etc.).

In my project I do have Login.jsp, Index.jsp and also Welcome.jsp. They are under: src/main/web/Pages

I have read somewhere that in struts2 I need to but .action extension to url, but it doesn't work and also why in struts.xml is package name and namespace? what exactly needs to be there? I have read that is for page what it is going to display?

Struts2 NameSpace

Mohan.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting started with struts2 but having problems