Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 and Ajax help

 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I did small program, when I enter "Anderson" in text box , "Hi, Anderson will display on same page".

I created this program from number of source. I used Struts2 and Ajax.I dont know where is the error, I am learning this.

Index.jsp


Struts-config.xml


AjaxMethod.java
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you understand how Struts works? If not, this will be really difficult. So let's start with a basic Struts tutorial. Once you've got the basics down, it will be easier to add AJAX to the mix.
 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply,

Yes, I know struts2
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excuse me if I sound skeptical, but you made a couple of beginner-level mistakes in the code above, for example, Struts 2 will not invoke this method:

Can you make something like the above code work without AJAX? (yes, you'll have to reload the page).
 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right, I used struts1. Its not working.. Now I want to use struts2. But I know know how to send result to the index.jsp.

Please help me, I spent 1 week to do this.
 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In short I require such code in which I enter the name "anderson" in the same page "welcome andershon" should display.

flow :

(index.jsp)send "anderson" to -->(java file)Receive "aderson" in action class - > "Welcome anderson" in "index file"

Thank you

Please help, me I tried too much.
 
Ayan Biswas
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always use something like DWR (Direct web remoting) for AJAX call in your app.

 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This same thing happened in your previous, nearly identical topic. I get the feeling you want us to write your code for you rather than guide you to find the answers yourself.
There are a lot of things that have to line up perfectly to get AJAX to work, and if you start with an incomplete understanding of how Struts works, you will never get AJAX working.
Again, my advice is to get something working without AJAX, then adapt the program to use it. Start with the basic Struts tutorial I linked above.
 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Joe Ess & Ayan Biswas

Thank you for suggestion, I think you are right, i have to give some time to struts2.

thank you
Hardik
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great. Feel free to ask any questions you have while you get up to speed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic