java

Is there a way to dump a stack trace without throwing an exception in java?

I am thinking of creating a debug tool for my Java application. I am wondering if it is possible to get a stack trace, just like Exception.printStackTrace() but without actually throwing an exception? My goal is to in any given method, dump a stack to see who the method caller is. Any replies or thoughts concerning this would be reall...

In java, how to create HttpsURLConnection or HttpURLConnection based on the url?

I'm working on a project where I'm creating a class to run http client requests (my class acts as a client). It takes in a url and a request method (GET, POST, PUT, etc) and I want to be able to parse the URL and open a HttpsURLConnection or HttpURLConnection based on whether it is https or http (assume the given urls will always be cor...

FieldBridge for Timestamp in Hibernate Search

What is the FieldBridge for timestamp in HIbernate Search? @Field public java.sql.Timestamp approvedDate; ...

2d Array in Spiral Order

I'm trying to fill an array in spiral order. So far, I can print the array in spiral order, but is there a way to modify the array so that i can fill it in spiral order and then just print the array? I'd like it to go in decreasing order like a countdown. Please help! public class Spiral { public static void main(int m, int n) { ...

JDBC getConnection timeout issue

Hi, I have an application that uses connection pooling to get database connection from oracle9i release 9.2.0.4 database.Application is hosted in SJSAS 8.1 and the driver is ojdbc14.jar version 10.1.0.4. The problem I am having is datasource.getConnection() method is taking about 40 secs to throw an exception when the DB is down! This i...

check if a point exists in given area containing 4 vertices

refering to http://www.weather.gov/directives/sym/pd01008006curr.pdf, page 8, we are given an area with four vertices in geographic coordinate system(lat and long system). I want to check if a point with particular lat and long exists within that area. ...

Jar from HTML

A third party library I'm utilizing provided the JavaDoc HTML and associated bin files in a zip file. How can I create a jar file from the JavaDoc HTML? Thanks. ...

Compiling GWT code with a large number of parameters -- char limit on CreateProcess?

Hello all, I am trying to run an ant build script that compiles GWT. This script includes a large number of libraries, each with a relatively long path. My GWT code only touches some of these libraries; however, it is convenient to include all of the libaries from the lib directory that I use for this and all of the other applications...

java inserting special characters with preparedstatement fails

I am using an HTML form which sends <input type=hidden name=longdesc value='SMARTNET%^" 8X5XNBD'> this is done by the following javascript code: function masinsert(id) { var currentTime=new Date(); var button = document.getElementById("m"+id); button.onclick=""; button.value="Inserting"; var itemdescription = document.ge...

Is there any way to automatically execute JUnit testcases once with all logging enabled and once with all logging disabled to increase code-coverage and find subtle bugs?

I've found a solution, see my own answer below. Does anyone have a more elegant one? Assume the following class to be tested: public class Foo { private final Logger logger = LoggerFactory.getLogger(Foo.class); public void bar() { String param=[..]; if(logger.isInfoEnabled()) logger.info("A message with paramete...

Is statement.close() explicitly required in connection pooled environment?

I am using connection pooling in my application. My question is: Is it explicitly required to close statement before closing connection in case of connection pooled environment? In connection pooled environment connection is not getting closed, (but returns back to free connection pool). I had checked jdbc 4.0 functional specs. In poin...

Java classes that implement the Serializable interface

I need a list of classes that implement Serializable. Could you also tell me what kind of classes implement that interface? ...

Parameterized constructor in servlet.

Can I declare parameterized constructor inside servlet which is only constructor ? If no then why ? ...

In java, how to check if a method m changed the state of its receiver

I am trying to write a method which receives a serializable object (implements Serializable) o and a method m. The method should compare the state of o before invoking m and after invoking m, and tell if invoking m changed o. It should check if the bits representing o were changed after the methods. Ho can I do it? ...

Portlets - Keeping session alive from server side

Hi, I am implementing jsr 186 portlets, with some servlets to the mix to implement some ajax. The problem is if I only make AJAX calls for some time, I lose the session. Strangely, keeping alive the servlet session does not prevent the portlet session from timing out. Is there a way I can keep the session alive from within my servlets,...

New lines and browser/OS compatability

I have a form that accepts a list of values, each value being listed on a separate line of textArea. In my Servlet, I am tokenizing the string I recieve from that textArea based on the new line characters "\r\n", like so: String[] partNumberList = originalPartNumberString.split("\r\n"); This appears to work fine. I get an array of val...

Java: problem running a jar file in command line

Hi! I'm trying to call a class (main method) from command line (Windows) with Java. The class imports other classes (other jars). I always get "class not found exception" from a class that my main program imports. Here's what I tried: Add a CLASSPATH env. var with the path where the referenced lib resides (not working) I tried with ...

Use a custom classloader at compile time

Is it possible to specify a custom classloader for javac (or some alternative java compiler)? I'd love such a feat because it would allow me to compile classes that use classes that are only found by my special classloader. For the curious once: I'd write a classloder that connects to a database and creates classes based on the tables...

Re-compile a Java Class from Jar

I have an executable jar that has one class file with a wrong value. I requested that file from the author and corrected the value. Now I want to compile it and add the compiled class file into the jar and run it. Not surprisingly I get multiple "cannot find symbol" errors for references of custom object that were in the jar file. ...

ForEach and Facelets

Hello, My managed bean : public List<String> getLiQuickNav(){ System.out.println("I'm here..."); List<String> l = new ArrayList<String>(); l.add("toto"); l.add("tata"); l.add("titi"); return l; } My forEach : <c:forEach var="categorie" items="#{mainControleur.liQuickNav}"> <h:outputLabel value="${categorie}"/> </c:for...