• Post Reply Bookmark Topic Watch Topic
  • New Topic

Treat .js file as .jsp

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!,

I have a .js file that prints some HTML using document.write ().

It has included in more then 600+ JSP files.

Because of this .js file, the performance is getting down, as its size is 50 KB.

Now I am seeing a possibility where I can generate HTML using JPS, which is currently being generated by .js file.

So If I put JSP code in to .js file, I don't have to change all 600+ .jsp file that has included .js file.

But will application server (Weblogic 6.1) consider .js file with the JSP code as .jsp code?

Is there anyway out?

Reg,
Chetan
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I got some optimization to my existing .js code

Presently




Proposed change




I believe this will improve somewhat performance, not up to the greater extend.

Reg,
Chetan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you would have to ask someone who knows more about JavaScript if your changes will improve things. The usually very reliable [url=http://"http://www.coderanch.com/t/116063/HTML-JavaScript/JavaScript-performance-tips"]Eric Pascarello[/url] suggested there was not much you could do. I'd take him at his word.

There are some application servers which support server side JavaScript; Weblogic is not one of them. Why was your code in JavaScript in the first place? Usually you only use JS if you specifically require client side processing, i.e. you want this table to be drawn in response to some client side event without having to make a request to the server. If you have no reason to have this table drawn client side, then it does make much more sense to let the JSP do it. To get that to happen you would need to re-write the JS as a JSP and include it in the other JSP's which need it.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul Sturrock!!

In fact I am fully agreed with Eric Pascarello�s view but I was just trying to find some work around solution.

I don�t see any significant of using client side JavaScript to draw a table, as table is not generating as per the client input, it is a static table for entire application. But YES they have used JavaScript to do so and included particular js file in all JSP files (600+).

I can achieve the same table using jsp page, but for that I have to change all (600+) JSP pages to include a jsp page that draw a table.

I can�t convince my client to update all jsp pages in the context.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!