java

how to reference a java .class file from a JSP page?

I have the JSP file (/page.jsp) in the root of my app directory. I want to use this class located in /WEB-INF/classes/Helper.class. I tried using the JSP page import statment with the class name but that didn't work. How can I reference Helper.class so that I can use it my JSP? I don't want to include the class in a package/JAR. ...

Measure Java's HttpConnection steps (header & body) for metric analysis?

Scenario I'm doing analytics of a data connection being made via Java's HttpConnection. Specifically, I want to measure: Time it took to receive the response header (not the full response) Time it took to download the data (not the full request, the response) To me, it seems as if the HttpConnection class is not sophisticated enough ...

implementing unification algorithm

Hello guyz .. I worked the last 5 days to understand how unification algorithm works in Prolog . Now ,I want to implement such algorithm in Java .. I thought maybe best way is to manipulate the string and decompose its parts using some datastructure such as Stacks .. to make it clear : suppose user inputs is: a(X,c(d,X)) = a(2,c(d,Y...

Java - where and how should exceptions be used?

Hello. I was reading some things about exception handling in Java, to be able to write better code. OK, I admit, I am guilty; I've used too much try-catch{} blocks, I've used ex.printStackTrace() in the catch, not even using a proper logger (actually the System.out and System.err were redirected to a PrintWriter, so a log was generated)....

Can I specify a different target tab/window in JSP with a RequestDispatcher

I have a JSP program that displays a form where the user enters some criteria for a report. If the criteria fail validations -- missing fields, invalid dates, etc -- I want to redisplay the form with an error message. If the criteria pass, I want to display the report. But I want the report to be in a different tab or window, like if the...

Eclipse: stop code from running (java)

Sometimes, I'll run a program that accidentally contains an infinite loop or something. Eclipse will let me continue editing the program, but be super slow. How can I stop it? (Do I want to restart the JVM?) Restarting eclipse itself always works, but that breaks my workflow. ...

Learning Java recursion from book, Java, a complete reference

Learning about recursion and having trouble with the code posted below, in line 6, int result=fact(n-1)*n; When I delete "fact" the program acts like I think it would, printing out: Factor of 3 6 Factor of 4 12 Factor of 5 20 but with the "fact" in it gives the output below? What is this line doing, and what is "fact" ? thanks ev...

Necessary and sufficient validations upon application init

Hello again. I have a new puzzle for you :-). I was thinking on how should an application handle his own start up. Like : checking for required libraries, correct versions, database connectivity, database compatibility, etc. To be specific, here is the test case. I use SWT and Log4J, for obvious reasons. Now, the questions : Should ...

Java: Serializing String[] Array to store in a MySQL Database?

Yes, I know it's bad practice and I should instead normalize my tables. That put aside, is it possible to serialize a String [] array and store it in the database? I am from the lenient and forgiving world of PHP, where invoking the serialize() function and would convert the array into a string. Is there an equivalent of doing such her...

Isn't Swing's JPanel pretty much like AWT's Panel? The former's widget is not showing up

I'm changing a program from AWT to Swing, as proposed on the second chapter of Java Swing's book, and the panel just disappears when I do the change from Panel to JPanel. The same doesn't happen when I change from Button to JButton. It seems to be a bug, since it appears to be trivially simple to do so - just adding an extra J to the na...

Java: function for arrays like PHP's join() ?

I want to join a String[] with a glue string. Is there a function for this? ...

Java Compute SHA-1

I'm looking for a way of getting an SHA-1 checksum with a Java byte array as the message Should I use a third party tool or is there something built in to the JVM that can help? ...

Cannot assign LinkedList to List, why?

Hi everyone, I'm using Java in Eclipse on Mac OS X 10.5 (JDK Compliance level 5.0) with and I'm getting very strange compilation problems that I wasn't getting before (and I don't think I've updated my compiler or Eclipse, but maybe an update was installed that I wasn't aware of). For example if I have the following line in my code: Li...

How do I flip a polygon by flipping the array?

I have 2 arrays of ints I am using to create a polygon (that looks like a fish). What do I need to do to the arrays to flip the polygon horizontally? x = new int[] { 0, 18, 24, 30, 48, 60, 60, 54, 60, 48, 30, 24, 0 }; y = new int[] { 0, 18, 6, 0, 0, 12, 18, 24, 24, 36, 36, 30, 36 }; ...

What is a lightweight, fast, java servlet container?

I have been writing a pure java web server specifically customized for a website I'm making. I've grown tired of reinventing the wheel though, and am now investigating moving over to java servlets. Basically I just want to run server side java code while leveraging the servlet technology to avoid writing http protocol specific code. I...

writing a portable domain specific language

I'd like to know good strategies for deploying a domain-specific-language which must run under at least 2 languages (Java, C#) and probably more (Python, and possibly Javascript). Some background. We have developed and deployed a domain-specific language currently written in C#. It's deployed though a series of method calls whose argume...

Any form generator(from annotated javabeans) for swing?

I've seen several form generators(swing, web etc from javabeans) but cannot find them again. Help me with links please. PS generator is not designer, generator - generates ui semi-automatically, no drawing is needed PPS I have finally found them nakedobjects jmatter metawidget if you know more please comment ...

appfuse: should I configure jdbc credentials twice?

New to appfuse - I like the concept. I configured the username/password to the database in jdbc.properties. It didn't work. So I also configured my credentials in pom.xml Why is it so? Am I doing something wrong? ...

Problem with printing inside the loop: for

Hi, I have problem reading/println after the first two FOR loop in this method. This is strange. How can I solve this problem? private int spacing() { int n = numberOfTriangles(); ArrayList<Double> list_Xs1 = new ArrayList<Double>(); ArrayList<Double> list_Ys1 = new ArrayList<Double>(); for(Polygon p:triangles){ double cX =...

read/write excel file in java

i just want to read and write a excel file from java.No complex calcutionns needed I just want to creat a excel sheet with 3 col and n rows. Like printing one string in each cell. Can anyone giv me simple code snippet ofr this? Do i need to use any external lib or do java have build in support for it? i want to do following for(i=0 ;i...