0

I have a Java EE web application and I want to use server side jQuery to process some HTML. Here's the process -

  1. User installs a chrome extension that I wrote
  2. User visits a web page on their browser
  3. The chrome extension selects an element on the page and puts it in a string. By element, I mean a <div> with numerous child elements (that may have their own child elements, etc...)
  4. The chrome extension then sends the HTML string by AJAX to a server
  5. On the server I then want to process this HTML using jQuery.

I could do the processing in the client's browser, but I choose to send it to the server because I don't want the javascript/jquery code to be available to everybody.

So, is it possible to use jQuery on the server to process HTML?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
sonicboom
  • 4,928
  • 10
  • 42
  • 60
  • I suppose you could set up a node.js server or something that runs jQuery, but frankly it's really not worth the hassle. If you're worried about someone nicking your jQuery code, don't be: nobody cares about it. If you have some super secret algorithm (encryption etc) you can send data from the client to the server for processing and send back the result. – JJJ Dec 29 '12 at 12:35
  • [Jsoup](http://jsoup.org/) has 'jQuery like' functions for working with an HTML DOM. Alternatively you could load up the main jQuery script via Java Scripting API and use it that way. Not sure how you would handle the HTML data though - there would be no DOM. Or you could externalize the whole process like @Juhana suggested and call into the external program from your Java code. – Perception Dec 29 '12 at 12:37
  • @Juhana It's not a super secret algorithm but if someone decided to write an application like mine it would save them hundreds of man hours if they could just take the code I've written and use it in their application. – sonicboom Dec 29 '12 at 17:36

0 Answers0