[Solved] IE8/Firefox Behavioral Difference

Since the lost focus seems to happen every 6000 milliseconds, I’d point the blame somewhere at expandone()/contractall() in /js/qm_scripts.js. Your login form is in the “dropmsg0” div, causing it to be briefly hidden and redisplayed every 6 seconds. The textboxes lose focus in IE8 when hidden. I’d either rename the div to exclude if from … Read more

[Solved] Why am I getting “No suitable driver found for jdbc:mysql://localhost:3306/test2”?

You need to load the com.mysql.jdbc.Driver driver class. private static final String DRIVER_NAME=”com.mysql.jdbc.Driver”; Look at the official documentation: The name of the class that implements java.sql.Driver in MySQL Connector/J is com.mysql.jdbc.Driver. The org.gjt.mm.mysql.Driver class name is also usable for backward compatibility with MM.MySQL, the predecessor of Connector/J. Use this class name when registering the driver, … Read more

[Solved] null pointer exception in java servlet [closed]

I got a “null pointer exception” fault in java servlet. Could someone tell me what happens? And how to avoid that? That happens when you’re trying to access/invoke some reference which is actually null. SomeObject someObject = null; someObject.doSomething(); // Throws NullPointerException. You need to make sure that you only access/invoke it when it is … Read more

[Solved] compare HashMap and ArrayList java

You can compare like below Code: List<String> global = new ArrayList<String>; Map<String, ArrayList<String>> newMap = new HashMap<String, ArrayList<String>>(); Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>(); for (String key:map.keySet()) { List<String> arrayList= map.get(key); for (String words:arrayList) { List<String> newList = new ArrayList<String>; for (String globallist:global) { if(words.equals(globallist)){ newList.add(words); } } newMap.put(key,newList); } } 1 solved compare … Read more

[Solved] why apache servlet is singleton? [duplicate]

Its an issue and it is never advisable to declare HttpServletRequest request/HttpServletResponse response as an instance variable. Actually Servlet is implementing single thread model that means only one servlet instance is created. And one thread for each request. So if their are many requests then thr must be many threads and each sharing same servlet … Read more

[Solved] Why isn’t this JSP – Servlet code work?

A NullPointerException, most of the time, means that you’re dereferencing a null variable. I assume the line causing the exception (line 97 in z.java, as the stack trace indicates) is the following line: yy.getXs().add(s); Then it can mean two things: yy is null The list returned by yy.getXs() is null. Use a debugger to identify … Read more

[Solved] How to display an image using inputstream in servlets?

You need write the image as a byte array to the response’s output stream. Something like this: byte[] imageBytes = getImageAsBytes(); response.setContentType(“image/jpeg”); response.setContentLength(imageBytes.length); response.getOutputStream().write(imageBytes); Then in you JSP you just use a standard img element: <img src=”url to your servlet”> Source: https://stackoverflow.com/a/1154279/1567585 solved How to display an image using inputstream in servlets?