• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Hi 'm strugling lot to run a simple hello world prgm  RSS feed

 
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are my files:
Index page: (proj/)

web.xml: (proj/WEB-INF/)

struts-config.xml: (proj/WEB-INF/)



helloWorld.jsp (proj/pages/)

helloWorld.java: (proj/WEB-INF/classes/com/salsa/)

'm trying this for 3 days

i got the index page with a button"submit" if i click on it:

"Error the requested resource (/helloWorld)is not available."

Can anyone help me to execute this prgm. it would be a grt help for me
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I don't see the XML declaration in your web.xml.
2. Your HelloWorld class is an action not a servlet, you should map ActionServlet in your web.xml and not your own class.
3. The ActionServlet is generally mapped to *.do extension in web.xml.
4. Your form would not submit to /helloWorld (unless you are deploying your application on ROOT path. You should add a ${pageContext.request.contextPath} before it so that it will contain the context path. So your form should submit to something like /proj/helloWorld.do (assuming proj is the context path)
 
manikandan jayakumar
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the changes in web.xml

hope its correct. But i cant get the 4th point of your reply post.
can you explain it? please
 
manikandan jayakumar
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have included the code

to my execute method of action class so that i may check whether the control is reaching this method
and executed the code same error and not getting the out.txt file too; its not working

So the prob would be with form tag and action mapping.
 
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the URL you see in your address bar?
Like,

http://hostname:port/proj/helloworld


or

http://hostname:port/helloworld


It all depends on your action attribute of form element in your JSP. If it doesn't contain a leading '/', the former would result. On the contrary, if it does contain a leading '/', the latter would result, which isn't obviously the desired one. I'd advise you to use

in your JSP.

Also you don't need to write to a file for checking if a section of code is reached, you could use Sysouts, loggers or even debug with IDE.
 
manikandan jayakumar
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
index.jsp


strutr-config.xml


now also getting error
"The server encountered an internal error () that prevented it from fulfilling this request."
javax.servlet.ServletException: org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
Orton K Randy
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What URL do you see in the address bar again? If it is:

http://hostname:port/proj/helloWorld.do



then the error simply means the actionmapping for /helloWorld is missing in the struts-config.xml(or it can't find the struts-config.xml at all). You could check that by getting rid of the form from the JSP altogether and simply having a single link to trigger the action, like:
assuming you declared
and have the necessary JARs in place.

Start with how to build Struts applications in case you're not confident of proceeding.

 
manikandan jayakumar
Ranch Hand
Posts: 44
Firefox Browser Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Randy
I got the output by your guidance.
thanks a lot now 'm going to extend the proj to get stud details.
 
Orton K Randy
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad that I could help.
 
Everybody! Do the Funky Monkey! Like this tiny ad!
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!