Saturday, September 24, 2011

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

The jsp page gives the following error : The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

Even if you include this:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

in your jsp page, it still gives the error.

The reason is that it depends upon the web app version. The web app version is defined in the web.xml file as follows:

Here’s an example of what to look for in web.xml:
<?xml version="1.0" encoding="UTF-8"?>

  web-app-25
...

You can see the version="2.5" designation in here. This means that within this web application, we will be able to use JSP 2.1 and JSTL 1.2 features.


Here, the web app version is 2.3.

So, if you are using web app version 2.3, then we should use :

<%@taglib prefix="c" uri="http://java.sun.com/jsp/core" %>

For Web app versions 2.4 & 2.5, you should use:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


Complete Error Trace:


WARNING: /SpringDemo/customer.htm:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:316)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:147)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:286)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:171)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:239)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1072)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:808)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:726)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:636)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:556)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:616)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)


Reference : http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/

Friday, September 23, 2011

java.lang.UnsupportedClassVersionError: Bad version number in .class file

java.lang.UnsupportedClassVersionError: Bad version number in .class file

[at java.lang.ClassLoader.defineClass1(Native Method)]

is an error that you may face in running a compiled java class file.

So as you can see from the stack trace, a class has not been loaded. But which class?

The problem is this error message does not show the name of the failed .class, isn't it?

No, it is not. This error is caused when you compile a .java file with one version of JDK and running the .class file with a different version of JVM.

Confused? You may say; same version is not required to compile and run.

Yes, that is true. But you can not run .class files that are compiled with a newer version than the JVM.

Say;

javac (compile) - version: X
java  (run)     - version: Y

If X is newer than Y; then you may face this issue at runtime.


Reference : http://lkamal.blogspot.com/2008/04/javalangunsupportedclassversionerror.html

Here is the supporting example.

Set the path to 1.6 for compilation
C:\Users\Yogi\Desktop>set PATH="C:\Program Files\Java\jdk1.6.0_10\bin";%PATH%

C:\Users\Yogi\Desktop>javac test.java

Now run the class using 1.5 jre
C:\Users\Yogi\Desktop>set PATH="C:\Program Files\Java\jre1.5.0_06\bin";%PATH%

C:\Users\Yogi\Desktop>java test
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n
umber in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


Friday, September 16, 2011

Javascript : How do I open a new browser window?

Source : http://www.javascripter.net/faq/openinga.htm

Question: How do I open a new browser window?

Answer: To open a new browser window, use the window.open() method. For example, the following code opens this page in a new window.
myRef = window.open(''+self.location,'mywin', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');


The general syntax of the window.open() method is as follows:

winRef = window.open( URL, name [ , features [, replace ] ] )

The return value, stored in the variable winRef, is the reference to your new window. You can use this reference later, for example, to close this window (winRef.close()), give focus to the window (winRef.focus()) or perform other window manipulations.

The parameters URL, name, features, replace have the following meaning:

URL String specifying the location of the Web page to be displayed in the new window. If you do not want to specify the location, pass an empty string as the URL (this may be the case when you are going to write some script-generated content to your new window).


name String specifying the name of the new window. This name can be used in the same constructions as the frame name provided in the frame tag within a frameset <frame NAME=name ...>. For example, you can use hyperlinks of the form <a target=name href="page.htm">, and the hyperlink destination page will be displayed in your new window.


If a window with this name already exists, then window.open() will display the new content in that existing window, rather than creating a new one.



features An optional string parameter specifying the features of the new window. The features string may contain one or more feature=value pairs separated by commas.
replace An optional boolean parameter. If true, the new location will replace the current page in the browser's navigation history. Note that some browsers will simply ignore this parameter.


The following features are available in most browsers:
toolbar=0|1	 Specifies whether to display the toolbar in the new window.
location=0|1	 Specifies whether to display the address line in the new window.
directories=0|1	 Specifies whether to display the Netscape directory buttons.
status=0|1	 Specifies whether to display the browser status bar.
menubar=0|1	 Specifies whether to display the browser menu bar.
scrollbars=0|1	 Specifies whether the new window should have scrollbars.
resizable=0|1	 Specifies whether the new window is resizable.
width=pixels	 Specifies the width of the new window.
height=pixels	 Specifies the height of the new window.
top=pixels	 Specifies the Y coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)
left=pixels	 Specifies the X coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)

JS Beautifier

I wish someone could format the unformatted javascript code

Here it comes true...


http://jsbeautifier.org

Check this out....Its Free and Amazing...

Another very useful site for javascript is

http://jsbin.com


How to disable touchpad in Lenovo Z560 touchpad

How to disable touchpad in lenovo ideapad Z560?


I know this post is not related to Java/J2ee, but I wanted to note down this solution somewhere. So storing it here.

Actually, the shortcut key for disabling touchpad (Fn+F6) is not working for me, because, F6 button of my keyboard is damaged.

I struggled for a week to find a solution of how to disable touch pad.

On google I saw various posts which say that there is an option of disabling touch pad in Control Panel -> Mouse -> Touch pad Tab

But I didn't find any such Tab.

After that I installed the touch pad driver from

Touchpad Driver for ideapad Z560

And I got that option in Control Panel -> Mouse.

Now I am happy....