I've got some production code that does something like:
HttpServletRequest httpServletRequest
...
DataInputStream dis = new DataInputStream(httpServletRequest.getInputStream())
These streams are never closed explicitly. I'm assuming here that the servlet container manages this (JBOss Web). What is the correct way to handle this?
...
Languages that have closures, such as Ruby, enable elegant constructs to transform lists. Suppose we have a class
class QueryTerm {
String value;
public String getValue() {...}
}
and a list of terms List<QueryTerm> terms, that we want to transform into its list of values List<String> values.
In Ruby we could write something like:...
How many JSPs to create to maintain one table for data entry. Add.jsp to enter a new record and Update.jsp to update an already entered record. Is this a good idea or create only one jsp and use that for add and update using some parameter as all the fields and functionality remains same. Only difference is at the time of update few fiel...
Hi,
is there any way to take a Criteria (that has multiple Criterias, Restrictions and Orders) and generate a HQL query out of it?
Cheers
Nik
...
I wrote a little code like this to start an ftp server embedded in my application. It's based on apache ftpserver
I found that anonymous user could not login. Client keeps get 530.
Do I have add a configure file for ftp? I can not find any API to create a User to add to UserManger.
private void start_ftp() throws FtpException {
...
I've extended FutureTask from java.util.concurrent to provide callbacks to track the execution of tasks submitted to an ExecutorService.
public class StatusTask<V> extends FutureTask<V> {
private final ITaskStatusHandler<V> statusHandler;
public StatusTask(Callable<V> callable, ITaskStatusHandler<V> statusHandler){
sup...
I'm simulating a overload of a server and I'm getting this error:
java.lang.OutOfMemoryError: unable to create new native thread
I've read in this page http://activemq.apache.org/javalangoutofmemory.html, that I can increase the memory size. But how do I do that? Which file I need to modify,? I tried to pass the arguments by the bin/a...
I can't get my program to compile!
i think im missing a curly brace but can't for the life of me see where!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.text.*;
import java.net.*;
...
I am using the Xerces implementation within JDK6 to perform XPath queries on an HTML 4.0 transitional document. With the following code:
XPath newXPath = XPathFactory.newInstance().newXPath();
XPathExpression xpathExpr = newXPath.compile(expression);
Object xPathResult = xpathExpr.evaluate(inputSource, XPathConstants.NODESET);
Where...
Hi community!
I have a multithreaded Java code in which:
several threads read stateful objects from the synchronized shared storage (i.e. as a result of this, some threads may reference the same objects);
each thread then invokes a method process() and passes its object there;
process() processes objects in some way, which may result ...
What is the best way to find out i java.io.InputStream contains zipped data?
...
Here is the typical way of accomplishing this goal:
public void myContractualMethod(final String x, final Set<String> y) {
if ((x == null) || (x.isEmpty())) {
throw new IllegalArgumentException("x cannot be null or empty");
}
if (y == null) {
throw new IllegalArgumentException("y cannot be null");
}
/...
Hi guys,
Every so often, I get a "org.hibernate.QueryException: duplicate association path: myAssociation". This is because the complex criteria I'm working with can define the same path in many places. I'd love to do something like
Criteria association = myCriteria.getAssociation("wax");
if(association == null) association = myCriteri...
http://pastebin.com/m64305b4
Appreciate any help.
...
How do you add an event listener or handler to widgets in GWT 1.7?
I know there are some questions alreayd about this on SO but it seems they are outdated.
For example (ignoring the fact that there is a :hover in CSS) how do I add a Hover listener to a FlexTable for example?
...
What is the standard way to implement simple update?
Example: we have User with phone number NNNNNN and now we want to set it to YYYYYY.
@PersistenceContext
private EntityManager em;
public void update (User transientUser) {
what should be here?
}
User entity is as simple as possible:
@Entity
@Table (name = "USER")
public clas...
Is there a way to VIEW the HTML source code that GWT produces? Currently I just give my flex table the DIV id and that DIV is all HTML I can see in ViewSource.
Is there a way to structure my table in HTML (say using div's and lists) and than create a something like FlexTable around that?
...
I have used Axis wsdl2Java, I am wondering is there any other way to create web service client?
...
In java is there a way to call a void method from a constructor.I try something like this but get an error message that the compiler can not find symbol method printThis(java.lang.String):
public class Date{
public Date(String inString){
String s = inString;
String b;
b.printThis(s);
}
public void printThis(getString)
...
It's a very simple question: can faces-config.xml file have multiple tags (more like SHOULD they have)? I'm working in a JSF project and the faces-config.xml file has something like this:
<application>
<el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<mes...