Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jsp and Ajax  RSS feed

 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Our requirement is like this

We need to validate and externals sites URL ,based on the return value if the URL is active or not we have to perform some logic in JSP.This jsp page doesnt have any <form>'s and it is been included in some other jsp.

So to perform the logic we failed using java method as it is giving "UNKnownHostException".
So we have used AJAX to perform the URL validation function.we have placed the AJAX function in the same JSP.
Here the problem is even before the AJAX completes validating the URL,the JSP logic gets completed.We have tried with synchrounous ajax call but,doesnt work out for us.We need a way to achieve this,please provide your suggestions.

We appreciate your help.

Thanks in advance,
Sarath
[ September 27, 2008: Message edited by: Sarath Chandra ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So to perform the logic we failed using java method as it is giving "UNKnownHostException".


Isnt that what you want? You should catch the exception and decide that the URL is bad.

we have to perform some logic in JSP.This jsp page doesnt have any <form>'s and it is been included in some other jsp.


What a tangled mess. You should not be performing logic in JSP, only HTML formatting. Back off a bit and redesign your application.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sarath Chandra:
Here the problem is even before the AJAX completes validating the URL,the JSP logic gets completed.We have tried with synchrounous ajax call but,doesnt work out for us.We need a way to achieve this,please provide your suggestions.

JSPs will execute on the server long before any JavaScript and Ajax will execute on the client. William is correct. You need to refactor your application. All processing should happen in the controller before your JSP even gets invoked.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!