Monday 15 February 2010

How can I reference a javascript library from a JSP in a java web application? -


I'm trying to create a table with sorted columns using the JavaScript library I provided. The web application is being created in Java and the table is created but with the CSS style I am 100% new to HTML and Javascript and just started trying to learn things today.

I have kept the library in the same source folder as JSP and are also in the root of the project, but both tables have been created in standard HTML format without script formatting. How to reference JavaScript library from a JSP in Java Web App?

I have made some progress but I can not get it to work properly. This is my WelcomePage.jip file:

  & lt;% @ Page content type = "text / html" page encoding = "UTF-8"%> & Lt;% response.setHeader ("Refresh", "5");%> & Lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Title & gt; Title & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "sorttable.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P & gt; & Lt; A href = url target = \ "_ blank \" & gt; Start & lt; / A & gt; & Lt; / P & gt; & Lt; Table class = "sort" & gt; & Lt; TR & gt; & Lt; Td> Text & lt; / Td> & Lt; Td> Text & lt; / Td> & Lt; Td> Text & lt; / Td> & Lt; Td> Text & lt; / Td> & Lt; Td> Text & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

I have tried to put it in Meta-INF, Web-INF and root folders, none of them is working properly. I have also tried to add it to a web.xml file but nothing is working.

file hierarchy

Some things that I have already tried < / P>

In the root of your application, or Place there under the / script folders. Web-INF and Meta-INF are not accessible from the outside.

If it is not accessible, check logs, try to open JS file manually in the browser, and firebug (or similar devices) if there are no JavaScript errors.

Then, if everything is okay, then I think you need to turn on some functions and pass the table ID.

No comments:

Post a Comment