Solved

JSP with ajax

Posted on 2014-01-30
9
709 Views
Last Modified: 2014-02-03
Hi there,

I am new to ajax. Would you use ajax with jsp ? jsp already has its own setProperty , getProperty.

Any feedback is greatly appreciated. Thanks.
0
Comment
Question by:zizi21
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 300 total points
ID: 39822924
>Would you use ajax with jsp  
AJAX is a  client-side  technique.  Using AJAX a browser can communicate with a server in the background without refreshing the page. JSP is a server-side technology. AJAX and JSP don't have much to do with each other. AJAX code could send a  request to a JSP, but it probably   is easier to  use a Servlet instead.    
>jsp already has its own setProperty , getProperty.    
What communication do you want between the client and your server?
0
 

Author Comment

by:zizi21
ID: 39823027
I am using java and jsp to read, write and delete data from the database. That is my communication between client and server. I am using setters/getters and when there is a need, i use redirect.
0
 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 100 total points
ID: 39823035
Ajax is a technique to send Asynchronous XMLHttpRequest to server side.

Whereas JSP is a scripting language used at client (UI) side. Inside JSP you can use Ajax to hit server request and handle the response.

You should have basic Javascript knowledge to understand Ajax.

You will get lots of online example on "Ajax calls from Jsp" on Googling..
0
 
LVL 27

Expert Comment

by:rrz
ID: 39823248
>I am using java and jsp to read, write and delete data from the database    
AJAX  could call a Servlet to do those things. The Servlet could respond with the new data and and you could use javascript to display it on the page.  
Of course, a JSP could generate the page that contains the AJAX code. But AJAX and JSP shouldn't  interact with each other.    
You should give us more details describing the flow of your web application.  
Have you considered using any  frameworks?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 26

Assisted Solution

by:mrcoffee365
mrcoffee365 earned 100 total points
ID: 39825213
Using JSP is fine.  Ajax is not related to whether it's a jsp or whatever on the server which is responding.  Servlets are not required to use Ajax.

As several people have responded correctly, Ajax is javascript which runs on the client -- a browser.  JSP only runs on the server.  JSP does not include getProperty or setProperty.  It's possible you're thinking of beans?  In any case, since Ajax is javascript (not java) which runs in the client and not the server, there's no possibility of conflict.
0
 
LVL 27

Expert Comment

by:rrz
ID: 39825252
mrcoffee>Using JSP is fine.  
Ok, as long as you can avoid any unintentional white space characters.
0
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 39825882
Ajax is usually using text -- extra whitespace is generally not a problem.  It can be, but it's not a great idea to scare new users with edge conditions.

Perhaps you're thinking of PDFs?
0
 
LVL 27

Expert Comment

by:rrz
ID: 39825980
mrcoffee>Perhaps you're thinking of PDFs?  
No.  
JSP is good for generating  the initial view.  But, I really think that using a Servlet for AJAX communication is better than using JSPs.
0
 

Author Comment

by:zizi21
ID: 39829903
Thanks all for the comments. .
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now