aspose file tools*
The moose likes Struts and the fly likes Struts2 and Ajax help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 and Ajax help" Watch "Struts2 and Ajax help" New topic
Author

Struts2 and Ajax help

Hardik Patel p
Ranch Hand

Joined: Jan 23, 2014
Posts: 34

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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Hardik Patel p
Ranch Hand

Joined: Jan 23, 2014
Posts: 34

Thanks for reply,

Yes, I know struts2
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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

Joined: Jan 23, 2014
Posts: 34

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

Joined: Jan 23, 2014
Posts: 34

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

Joined: Jul 10, 2010
Posts: 104
You can always use something like DWR (Direct web remoting) for AJAX call in your app.


AyanBiswas
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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

Joined: Jan 23, 2014
Posts: 34

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

Joined: Oct 29, 2001
Posts: 8908
    
    8

Great. Feel free to ask any questions you have while you get up to speed.
 
Don't get me started about those stupid light bulbs.
 
subject: Struts2 and Ajax help