File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Dynamic table with jsp-servlet-javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Dynamic table with jsp-servlet-javascript" Watch "Dynamic table with jsp-servlet-javascript" New topic
Author

Dynamic table with jsp-servlet-javascript

Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 13
Good morning.
I want to do an application that, when I start to put my text in the text box, my table automatically refreshes.
I saw this before, I think with jquery, but I want to know how to do this with javascript and/or jsp and servlets.

I searched on google without success..
Someone can help me?

obs.: I don't want to use frameworks like jsf or jquery (if possible).

thank's.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

Why would you not want to use jQuery? It makes JavaScript a lot simpler. It's like saying you don;t want to use Java libraries and do everything yourself. Rather short-sighted.

In fact, with jQuery your problem is almost trivial.

In any case, this has been moved to the HTML/JavaScript forum.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 13
Ok, if will be most simply with jQuery have no problem..
We have one way through where we can do that without javascript?
Are you sure that this topic need to be moved to javascript forum? Because we will use parameters from servlet..
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

If all you want to refresh is that table, then there is no way to do this without JavaScript unless you embed the table in a fixe iframe (which is a lousy solution, in my opinion).
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

In fact, using jQuery it's one line of code:
Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 13
Bear Bibeault wrote:In fact, using jQuery it's one line of code:



What the servlet have to return ??
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

The HTML of the updated table.

I've done this many times. The servlet gets the data for the table, and forwards to a JSP that uses JSTL and EL to create the table HTML.

the jQuery load() method replaces the old table with the new one.

Easy as pie.
Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 13
Bear Bibeault wrote:The HTML of the updated table.

I've done this many times. The servlet gets the data for the table, and forwards to a JSP that uses JSTL and EL to create the table HTML.

the jQuery load() method replaces the old table with the new one.

Easy as pie.


How would look like?

in servlet:


and jsp page:




Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

No need for any script on the table response.

In the table markup, you'd use the JSTL forEach tags to create the rows (<tr>) and columns (<td>) elements in order to create the table structure.
Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 13
Bear Bibeault wrote:No need for any script on the table response.

In the table markup, you'd use the JSTL forEach tags to create the rows (<tr>) and columns (<td>) elements in order to create the table structure.


but in this case can I do a dynamic table where when the user is typing the text, the table will filtering the results??

Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

I'm not sure exactly what you are asking, but yeah, this is the most flexible approach.
 
 
subject: Dynamic table with jsp-servlet-javascript
 
Threads others viewed
How can i integrate jQuery in Jsf ?
Directory Structure JSP & JS
Ajax with JSP and JSTL
XMLHtmlRequest return Undefine
How to do sorting after filtered the data in the HTML table
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com