Solved

JSP with ajax

Posted on 2014-01-30
9
722 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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
 
LVL 27

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 27

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 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