This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which server-side script takes the input from JavaScript in j2ee application

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendra Prakash wrote:Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.


Rajendra, your question (?) doesn't make sense, please clarify!

What are you trying to achieve, what are you having problems with? (Don't know how to pass parameters from JS to the server-side app? Don't know which scripting language can access those parameters? Don't know how to process them in a servlet in Java?? )
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript variables cannot be accessed in servlets. javascript is executed on the client side. You'll have to make a request to the server (maybe an Ajax call) to send the values of the javascript variables which you want to process on the server side...
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is how the usual AJAX script goes:

* Some action triggers the event, like the user clicking a button.
* The AJAX call fires, and sends a request to a server-side script, using XML
* The server-side script (PHP, ASP, or whatever) takes the input from JavaScript, can access the database if it needs to, processes the data.
* Using XML again, the script sends the data back to the original client-side page that made the request
* A second JavaScript function, called a callback function,catches the data, and updates the web page


From this lines i asked you
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The AJAX call fires, and sends a request to a server-side script, using XML

This is the key step. You'll have to send any request parameters to the server in the Ajax request. It can be sent as query string if the ajax request is a GET request or as request body if you are using POST Ajax request. Search on the internet for some tutorial on how to send parameters in an Ajax request...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendra Prakash wrote:Here is how the usual AJAX script goes: ... sends a request to a server-side script using XML ... Using XML again

XML is not used when sending the request to the sever, and XML is only one of many text formats that can be used for the response.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use jsp(server side scirpt ) to take the input from JavaScript, can access the database if it needs to, processes the data.
 
luke yu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course you can access database using jsp(scriptlet )
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendra Prakash wrote:Is it possible to use jsp(server side scirpt ) to take the input from JavaScript, can access the database if it needs to, processes the data.

Your question is still not clear. I hope this is not what you are expecting (as it is not possible)

"A page is opened in the user's browser. You set the value of a javascript variable to 10. The page is posted back to the server. You try to access the value 10 from the javascript variable"

As I said earlier, to send a request to the server using javascript, you'll either have to make an ajax request, or open a new pop-up window from javascript using window.open...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
luke yu wrote:of course you can access database using jsp(scriptlet )

Only if you want to dabble in extremely poor practices and write code like it's still 1998.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tonight I'm gonna code like it's nineteen..... nine...ty nine.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Only if you want to dabble in extremely poor practices and write code like it's still 1998.

David wrote:
Tonight I'm gonna code like it's nineteen..... nine...ty nine.


I completly Agree . but what to do ? . but somebody[most of the programmer(since maintenance project is more)] still need to code (change) java code in jsp. Even many small company use to code java in jsp in development project still(2009) .

if client pay for you to write this in 2009, you should... right?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one is talking about maintaining old pages, but coding new ones (or refactoring to bring pages that need lots of changes into the modern era).

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the business value for moving the code out of the JSPs is there anyway, as it makes things more testable (if done correctly), easier to document, and so on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic