|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
struts 2 helloWorld example not properly working in tomcat 5.5i'm trying to get the example outlined in http://struts.apache.org/2.1.8/docs/ready-set-go.html to work
i managed to compile the project in eclipse and it seems to be working with the exception that the output page is blank. i.e. the <body> <h2><s:property value="message" /></h2> </body> directive in the jsp doesn't seem to be outputing anything below are my struts.xml HelloWorld.java and HelloWorld.jsp struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="tutorial" extends="struts-default"> <action name="HelloWorld" class="tutorial.HelloWorld"> <result>/HelloWorld.jsp</result> </action> <!-- Add your actions here --> </package> </struts> HelloWorld.java package tutorial; import com.opensymphony.xwork2.ActionSupport; public class HelloWorld extends ActionSupport { public static final String MESSAGE = "Struts is up and running ..."; public String execute() throws Exception { setMessage(MESSAGE); return SUCCESS; } private String message; public void setMessage(String message){ this.message = message; } public String getMessage() { return message; } } HelloWorld.jsp <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Hello World!</title> </head> <body> <h2><s:property value="message" /></h2> </body> </html> all i'm getting is a blank page with "Hello World" as the title thanks for any replies, k |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5Hello,
your code and struts settings looks fine, so I guess the problem will be in the web.xml. How is set your Filter? What filter do you use? By the way, in struts page you sent, there is FilterDispatcher mentioned, but it is deprecated since 2.1.3. More about it here: http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/dispatcher/FilterDispatcher.html <http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/dispatcher/FilterDispatcher.html>Can you provide your complete web.xml? Jozef On Sat, Nov 7, 2009 at 9:19 AM, reason <kp@...> wrote: > > i'm trying to get the example outlined in > http://struts.apache.org/2.1.8/docs/ready-set-go.html to work > > i managed to compile the project in eclipse and it seems to be working with > the exception that the output page is blank. > > i.e. the > > <body> > <h2><s:property value="message" /></h2> > </body> > > directive in the jsp doesn't seem to be outputing anything > > below are my struts.xml HelloWorld.java and HelloWorld.jsp > > struts.xml > <!DOCTYPE struts PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > <struts> > <package name="tutorial" extends="struts-default"> > <action name="HelloWorld" class="tutorial.HelloWorld"> > <result>/HelloWorld.jsp</result> > </action> > <!-- Add your actions here --> > </package> > </struts> > > HelloWorld.java > package tutorial; > import com.opensymphony.xwork2.ActionSupport; > public class HelloWorld extends ActionSupport { > > public static final String MESSAGE = "Struts is up and running ..."; > > public String execute() throws Exception { > setMessage(MESSAGE); > return SUCCESS; > } > > private String message; > > public void setMessage(String message){ > this.message = message; > } > > public String getMessage() { > return message; > } > } > > HelloWorld.jsp > <%@ taglib prefix="s" uri="/struts-tags" %> > > <html> > <head> > <title>Hello World!</title> > </head> > <body> > <h2><s:property value="message" /></h2> > </body> > </html> > > > all i'm getting is a blank page with "Hello World" as the title > > thanks for any replies, > k > -- > View this message in context: > http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26240890.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5Hello,
it seems to me that problem could exist at any of the two place. #Either action class's execute method is not getting called. Add SOPs with message variable in execute method to verify that. #Either your action class's execute method is getting called but the value of the message variable is not getting retained while jsp is getting called. Lets first check out of these two which is the cause of error, only then we can investigate further. if you can provide snippets from struts.xml and web.xml , that would be really helpful... Regards Gaurav On Sat, Nov 7, 2009 at 9:19 AM, reason <kp@...> wrote: > > i'm trying to get the example outlined in > http://struts.apache.org/2.1.8/docs/ready-set-go.html to work > > i managed to compile the project in eclipse and it seems to be working with > the exception that the output page is blank. > > i.e. the > > <body> > <h2><s:property value="message" /></h2> > </body> > > directive in the jsp doesn't seem to be outputing anything > > below are my struts.xml HelloWorld.java and HelloWorld.jsp > > struts.xml > <!DOCTYPE struts PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > <struts> > <package name="tutorial" extends="struts-default"> > <action name="HelloWorld" class="tutorial.HelloWorld"> > <result>/HelloWorld.jsp</result> > </action> > <!-- Add your actions here --> > </package> > </struts> > > HelloWorld.java > package tutorial; > import com.opensymphony.xwork2.ActionSupport; > public class HelloWorld extends ActionSupport { > > public static final String MESSAGE = "Struts is up and running ..."; > > public String execute() throws Exception { > setMessage(MESSAGE); > return SUCCESS; > } > > private String message; > > public void setMessage(String message){ > this.message = message; > } > > public String getMessage() { > return message; > } > } > > HelloWorld.jsp > <%@ taglib prefix="s" uri="/struts-tags" %> > > <html> > <head> > <title>Hello World!</title> > </head> > <body> > <h2><s:property value="message" /></h2> > </body> > </html> > > > all i'm getting is a blank page with "Hello World" as the title > > thanks for any replies, > k > -- > View this message in context: http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26240890.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5many thanks for both responses.
the web.xml looks as follows: <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>helloStruts</display-name> <welcome-file-list> <welcome-file>HelloWorld.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>HelloWorld</servlet-name> <servlet-class>tutorial.HelloWorld</servlet-class> </servlet> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> i've removed references to the deprecated class but the result is still the same. it would appear that the execute method is not being called as i added the following code in there but saw nothing in the filesystem: try { BufferedWriter out = new BufferedWriter(new FileWriter("helloWorld")); out.write(MESSAGE); out.close(); } catch (IOException e) { } cheers, kostis
|
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5Hello,
couple of things: 1. Struts2 Action is not Servlet, so you don't need following part in your web.xml: <servlet> <servlet-name>HelloWorld</servlet-name> <servlet-class>tutorial.HelloWorld</servlet-class> </servlet> Based on your first email I assume that tutorial.HelloWorld is an action class, not Servlet. So please, remove this part. 2. Your action result page is also a welcome file, so if you run your application, it will display your HelloWorld.jsp file, but the Struts2 action will not be executed. (Check your address bar, if your URL ends with HelloWorld.jsp, this is the case). 3. So how to run your action? You have to call it... change the url so it ends with HelloWorld.*action, *this should trigger your action. You should probably know, that Struts is set by default to recognize only the *.action as Struts2 actions. Anything else is not treated as Struts2 action. You can change this in struts-default.xml if I am not wrong. But for this hello world example you don't need to do it. Just follow step 3 above to execute your action. Regards, Jozef On Mon, Nov 9, 2009 at 1:09 AM, reason <kp@...> wrote: > > many thanks for both responses. > > the web.xml looks as follows: > <?xml version="1.0" encoding="UTF-8"?> > <web-app id="WebApp_ID" version="2.4" > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> > <display-name>helloStruts</display-name> > <welcome-file-list> > <welcome-file>HelloWorld.jsp</welcome-file> > </welcome-file-list> > > <servlet> > <servlet-name>HelloWorld</servlet-name> > <servlet-class>tutorial.HelloWorld</servlet-class> > </servlet> > > <filter> > <filter-name>struts2</filter-name> > > <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> > </filter> > > <filter-mapping> > <filter-name>struts2</filter-name> > <url-pattern>/*</url-pattern> > </filter-mapping> > > > </web-app> > > i've removed references to the deprecated class but the result is still > the > same. > > it would appear that the execute method is not being called as i added the > following code in there but saw nothing in the filesystem: > try { > BufferedWriter out = new BufferedWriter(new > FileWriter("helloWorld")); > out.write(MESSAGE); > out.close(); > } catch (IOException e) { > } > > cheers, > kostis > > > Gaurav@Nabble wrote: > > > > Hello, > > > > it seems to me that problem could exist at any of the two place. > > > > #Either action class's execute method is not getting called. Add SOPs > > with message variable in execute method to verify that. > > #Either your action class's execute method is getting called but the > > value of the message variable is not getting retained while jsp is > > getting called. > > > > Lets first check out of these two which is the cause of error, only > > then we can investigate further. > > if you can provide snippets from struts.xml and web.xml , that would > > be really helpful... > > > > > > Regards > > > > Gaurav > > > > On Sat, Nov 7, 2009 at 9:19 AM, reason <kp@...> wrote: > >> > >> i'm trying to get the example outlined in > >> http://struts.apache.org/2.1.8/docs/ready-set-go.html to work > >> > >> i managed to compile the project in eclipse and it seems to be working > >> with > >> the exception that the output page is blank. > >> > >> i.e. the > >> > >> <body> > >> <h2><s:property value="message" /></h2> > >> </body> > >> > >> directive in the jsp doesn't seem to be outputing anything > >> > >> below are my struts.xml HelloWorld.java and HelloWorld.jsp > >> > >> struts.xml > >> <!DOCTYPE struts PUBLIC > >> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > >> "http://struts.apache.org/dtds/struts-2.0.dtd"> > >> <struts> > >> <package name="tutorial" extends="struts-default"> > >> <action name="HelloWorld" class="tutorial.HelloWorld"> > >> <result>/HelloWorld.jsp</result> > >> </action> > >> <!-- Add your actions here --> > >> </package> > >> </struts> > >> > >> HelloWorld.java > >> package tutorial; > >> import com.opensymphony.xwork2.ActionSupport; > >> public class HelloWorld extends ActionSupport { > >> > >> public static final String MESSAGE = "Struts is up and running ..."; > >> > >> public String execute() throws Exception { > >> setMessage(MESSAGE); > >> return SUCCESS; > >> } > >> > >> private String message; > >> > >> public void setMessage(String message){ > >> this.message = message; > >> } > >> > >> public String getMessage() { > >> return message; > >> } > >> } > >> > >> HelloWorld.jsp > >> <%@ taglib prefix="s" uri="/struts-tags" %> > >> > >> <html> > >> <head> > >> <title>Hello World!</title> > >> </head> > >> <body> > >> <h2><s:property value="message" /></h2> > >> </body> > >> </html> > >> > >> > >> all i'm getting is a blank page with "Hello World" as the title > >> > >> thanks for any replies, > >> k > >> -- > >> View this message in context: > >> > http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26240890.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@... > > For additional commands, e-mail: user-help@... > > > > > > > > -- > View this message in context: > http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26259905.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5Hello Jozef
Great bit of help, along with the other guys! After dozens of hours of frustration finally got the app running! Struts seem to have a steep learning curve but i'll get there in the end... ;) many thanks, kostis
|
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5Hello Kostis,
I am glad you finally got the app running! Your first app, my first comments in this forum... so I am double glad :-) Jozef. On Mon, Nov 9, 2009 at 2:07 PM, reason <kp@...> wrote: > > Hello Jozef > > Great bit of help, along with the other guys! After dozens of hours of > frustration finally got the app running! > Struts seem to have a steep learning curve but i'll get there in the end... > ;) > > many thanks, > kostis > > > Hello, > > couple of things: > > > -- > View this message in context: > http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26266984.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5using the maven archetype to get an app setup is a good idea, it can
save you a lot of frustration. musachy On Mon, Nov 9, 2009 at 6:07 AM, reason <kp@...> wrote: > > Hello Jozef > > Great bit of help, along with the other guys! After dozens of hours of > frustration finally got the app running! > Struts seem to have a steep learning curve but i'll get there in the end... > ;) > > many thanks, > kostis > > > Hello, > > couple of things: > > > -- > View this message in context: http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26266984.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5thanks musachy
that was actually my initial attempt but it ran aground (see below) so i gave up and did it the hard way [kostis@ares tmp]$ echo $JAVA_HOME;echo;echo;mvn archetype:create -DgroupId=tutorial -DartifactId=tutorial -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-starter -DarchetypeVersion=2.0.11 -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0 Warning: JAVA_HOME environment variable is not set. [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:create] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:create {execution: default-cli}] [WARNING] This goal is deprecated. Please use mvn archetype:generate instead [INFO] Defaulting package to group ID: tutorial [INFO] We are using command line specified remote repositories: http://people.apache.org/repo/m2-snapshot-repository Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/apache/struts/struts2-archetype-starter/2.0.11/struts2-archetype-starter-2.0.11.jar [INFO] Unable to find resource 'org.apache.struts:struts2-archetype-starter:jar:2.0.11' in repository id0 (http://people.apache.org/repo/m2-snapshot-repository) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error creating from archetype Embedded error: org.apache.maven.archetype.downloader.DownloadNotFoundException: Requested download does not exist. Unable to download the artifact from any repository [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6 seconds [INFO] Finished at: Tue Nov 10 14:02:53 EET 2009 [INFO] Final Memory: 8M/14M [INFO] ------------------------------------------------------------------------ [kostis@ares tmp]$ that's why i'm talking about a steep learning curve. it's all fun though... hihi |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5hum, I use this all the time:
mvn archetype:create -DgroupId=tutorial \ -DartifactId=tutorial \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-starter \ -DarchetypeVersion=2.0.11.2 I does take a few times setting it up to learn all the gotchas :) musachy On Tue, Nov 10, 2009 at 4:05 AM, reason <kp@...> wrote: > > thanks musachy > > that was actually my initial attempt but it ran aground (see below) so i > gave up and did it the hard way > > [kostis@ares tmp]$ echo $JAVA_HOME;echo;echo;mvn archetype:create > -DgroupId=tutorial -DartifactId=tutorial > -DarchetypeGroupId=org.apache.struts > -DarchetypeArtifactId=struts2-archetype-starter > -DarchetypeVersion=2.0.11 > -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository > /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0 > > > Warning: JAVA_HOME environment variable is not set. > [INFO] Scanning for projects... > [INFO] Searching repository for plugin with prefix: 'archetype'. > [INFO] > ------------------------------------------------------------------------ > [INFO] Building Maven Default Project > [INFO] task-segment: [archetype:create] (aggregator-style) > [INFO] > ------------------------------------------------------------------------ > [INFO] Setting property: classpath.resource.loader.class => > 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. > [INFO] Setting property: velocimacro.messages.on => 'false'. > [INFO] Setting property: resource.loader => 'classpath'. > [INFO] Setting property: resource.manager.logwhenfound => 'false'. > [INFO] [archetype:create {execution: default-cli}] > [WARNING] This goal is deprecated. Please use mvn archetype:generate instead > [INFO] Defaulting package to group ID: tutorial > [INFO] We are using command line specified remote repositories: > http://people.apache.org/repo/m2-snapshot-repository > Downloading: > http://people.apache.org/repo/m2-snapshot-repository/org/apache/struts/struts2-archetype-starter/2.0.11/struts2-archetype-starter-2.0.11.jar > [INFO] Unable to find resource > 'org.apache.struts:struts2-archetype-starter:jar:2.0.11' in repository id0 > (http://people.apache.org/repo/m2-snapshot-repository) > [INFO] > ------------------------------------------------------------------------ > [ERROR] BUILD ERROR > [INFO] > ------------------------------------------------------------------------ > [INFO] Error creating from archetype > > Embedded error: > org.apache.maven.archetype.downloader.DownloadNotFoundException: Requested > download does not exist. > Unable to download the artifact from any repository > [INFO] > ------------------------------------------------------------------------ > [INFO] For more information, run Maven with the -e switch > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 6 seconds > [INFO] Finished at: Tue Nov 10 14:02:53 EET 2009 > [INFO] Final Memory: 8M/14M > [INFO] > ------------------------------------------------------------------------ > [kostis@ares tmp]$ > > > that's why i'm talking about a steep learning curve. it's all fun though... > hihi > -- > View this message in context: http://old.nabble.com/struts-2-helloWorld-example-not-properly-working-in-tomcat-5.5-tp26240890p26282285.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: struts 2 helloWorld example not properly working in tomcat 5.5wehey! it worked :)
i'm positive i had copy/pasted that line from somewhere official. is someone playing tricks on us struts2 newbies????? evil bums! cheers, kostis
|
| Free embeddable forum powered by Nabble | Forum Help |