I frequently saw links to "external tag libraries" in jsp
Ex:
<%# taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
But I couldn't find answers to these questions:
Does use a tag library from an external web location?
Does it query that location every time the tag is used?
Does it download it only once?
when does the download happen?
Can I create my own tag library, and provide a similar external link to others?
Please edit this question if it's wrong, I never really asked questions of this type
A tag library is part of the application, no download is happening at runtime. The URL you see on the JSP page is just a namespace URI to bind the prefix used on the page to the tag library.
Yes, you can create your own tag library.
Please refer bold replies
Does use a tag library from an external web location? No
Does it query that location every time the tag is used? No
Does it download it only once? No download so no query
when does the download happen? Download never happens
Can I create my own tag library, and provide a similar external link to others? Yes
The uri you see the JSP page, is actually referenced from web.xml file, refer to jsp-config.
Related
I want to make the js and css files which are modified are to be downloaded at the client end when a page is accessed. I have these approaches
Manually add the modified timestamp the URL in each page.
I was thinking of writing a scriptlet code in all the jsp pages which will read all the js and css files modified timestamp and append it to the url in the page.
Add the modified timestamp while building the war file using ANT.
I have following questions.
Can any one let me know which would be a better solution of the above approaches? I am open to any other solutions also.
I went through this answer on SO and using it I can get the modified date but how to change the jsp file?
Is there anything similar to this in java?
In this situation better or best solution is took shape according to your exact requirements. I might derive simple questions like; Will your static resources in same server or included in your app in same server etc.. May be some other better ways..
I don't have ant experience so I can't talk about it now , but you can go with java way already.I want to share just idea/s. A filter(looks the .css or .js requests , gets resources and look resource lastmodified date or checksum return as version on response) or custom jsp tag will provide your requirements. Write a custom jsp tag <resource:static path="app.js"/> like that example. So it may look specific file's last modified date, assumed under the same document root, and it can produce <script type="text/javascript" src="app.js?version=8637"> like this result, so this result will bust the cache.
I have a working servlet code, which processes some command prompt commands and I have an editor code written in html, now I want to add this html file to servlet. How do I do it? tried moving the html file to WEB-INF.
I've looked into this link on How to integrate HTML design into Servlet? but everything seems damn cumbersome as I have a very large html file.
Any other fixes?
If your editor.html contains only static JS, CSS and HTML (you don't depend on the data provided by your servlet), you can simply forward your servlet into JSP and include your html page from it using
<%# include file="editor.html" %>
Recently I thought of creating a file uploader using JSP/Servlet. In the JSP page there will be a link. On clicking the link corresponding action class is called. So when the upload starts I must get the info status on my JSP page. But if the link is clicked again I must show that some message like one import is already running.
Is something like this already available? I don't want to reinvent the wheel.
One of the Jquery File Upload
http://www.phpletter.com/Demo/AjaxFileUpload-Demo/
You may find many more examples if you google it
Jquery has a bunch of file upload javascript libraries. Google it and see for yourself. JQuery is super simple to work with and works with Servlet libraries like Struts. Hope this helps!
I am trying to integrate CKEditor in Netbeans to my simple web application. I did follow the documentation given in their official site, but cudnt install. It just shows a textarea instead of the editor.
Is there any tutorial on how to integrate or can anyone help me on this?
Thanks,
Shilpa
it seems you are missing to load css & js files. please check again & tell me if css & js files is downloaded & working.
You just have get ckeditor folder from http://ckeditor.com and put it outside the WEB-INF folder.And keep the ckeditor jar file in WEB-INF/lib folder.If you use jsp page get the include this tag in your page
<%# taglib prefix="ckeditor" uri="http://ekeditor.com"%> and in the body section of the html page create one textarea and replace it with <ckeditor:replace parameters />.
If you want to write all the toolbars and events in java and get them into jsp page use script lets and import these libraries. <% import page="com.ckeditor.EventHandler"%>.
If you want more examples on java refer here http://svn.ckeditor.com/CKEditor.Java. Hope this helps.
I'm using #ResourceDependency annotation in a JSF component to add Javascript and CSS files into my JSF page.
In my Javascript file, I need to reference another resource file (a .swf file, which located in META-INF/resources, as JSF requires). I tried to put a #{resource['swf:file.swf']} EL expression in my javascript code, but it won't get resolved.
For exapmle, for the following JS file in the server:
var instance = new JSClass();
instance.setResourceUrl("#{resource['swf:file.swf']}");
The browser gets:
var instance = new JSClass();
instance.setResourceUrl("#{resource['swf:file.swf']}");
which is wrong.
While when I put the same EL in the CSS file, it get resolved properly. For the following CSS file in the server:
.instance-css-class {
background: url("#{resource['swf:file.swf']}")
}
The browser gets:
.instance-css-class {
background: url("/webapp/javax.faces.resource/file.swf.jsf?ln=swf")
}
Which is exactly what I need, but in the JS file.
Obviously, I can use the CSS as a workaround for the issue (Create a DOM element, attach the CSS class to it, and then read and parse the required style property). But, is there a more elegant way to achive it? Is it a bug in the JSF library (I'm using Mojarra 2.0.3, with Jboss 6.1), or there is a reason for that behavior?
Please mind that the code above is part of a tag library, so workarounds such as those can't be used.
Edit - Seems that the CSS workaround is not feasible, since I can't see a way to get CSS attribute from a CSS file. So any (working) workaround would be gladly accepted as well.
BalusC has answered a similar question in detail here. Though the first solution is the easiest to implement, I would recommend you to go with the third, which in my opinion, is the correct way.