Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

newbie, execute method not working

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I am very new to struts 2, I am starting my 1st page by just want to to show label "Hello I am here" in my index.jsp via HelloWorld class..
but the execute method not working?

index.jsp


struts.xml


and my HelloWorld.java




 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Is your HelloWorld class in example package??
2. What is the URL that you are entering in the browser??
3. The result configuration says that the result for HelloWorld action is a JSP named HelloWorld.jsp but you've shown us the code for index.jsp. Do you actually have a HelloWorld.jsp in example folder in your application??
4. How do you know the execute method is not getting executed??
 
luckay win
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Is your HelloWorld class in example package?? --> Yes
2. What is the URL that you are entering in the browser?? --> http://localhost:8080/WebApplication3/
3. The result configuration says that the result for HelloWorld action is a JSP named HelloWorld.jsp but you've shown us the code for index.jsp. Do you actually have a HelloWorld.jsp in example folder in your application?? --> No, that's typo ..it should be HelloWorld.jsp

web.xml


4. How do you know the execute method is not getting executed?? --> because I did not see anything in the browser .. it should be "Hello I am here"



please help me to start.. .. thanks
 
Ankit Garg
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are accessing the JSP page directly. You'll have to go through the action to see the message. Try the URL http://localhost:8080/WebApplication3/HelloWorld.action
 
luckay win
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I tried http://localhost:8080/WebApplication3/HelloWorld.action and got the following error message:

HTTP Status 404 - There is no Action mapped for namespace / and action name HelloWorld.

type Status report

messageThere is no Action mapped for namespace / and action name HelloWorld.

descriptionThe requested resource (There is no Action mapped for namespace / and action name HelloWorld.) is not available.
GlassFish Server Open Source Edition 3.0.1


what happen with my struts.xml? or where should I put struts.xml ? .. currently it located under WEB-INF

 
luckay win
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also had checked http://struts.apache.org/2.1.8/docs/simple-setup.html.. and I have exactly the same web application structure

/example/
/example/META-INF/
/example/WEB-INF/
/example/WEB-INF/classes/struts.xml
/example/WEB-INF/lib/
/example/WEB-INF/web.xml
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well is it problem if we create two jsp pages? It is more attractive
Firts off all your struts.xml file must be located in <default package> in the "source packages" directory.
web.xml must be in WEB-INF directory.
our jsp pages should be in WEB-PAGES directory(it is default) or you may create another folder for it.

So i create two pages index.jsp and helloworld.jsp
index.jsp page simply show a button and asks user to click on it then helloworld.jsp show the message "Hello World i am here".

web.xml file this is:


struts.xml file this is:


the HelloWorld Class :




The index.jsp page:




and the last one helloworld.jsp page:



Thanks
 
luckay win
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks and yes it works with 2 .jsp ..

but still don't understand why it does not work if just 1 .jsp..

 
Shahriyar Rzayev
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

luckay win wrote:Thanks and yes it works with 2 .jsp ..

but still don't understand why it does not work if just 1 .jsp..



maybe with redirection it will possible to do such thing. but 2 pages are better
 
Space pants. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic