java

How to escape-html in JSP before saving to database ?

Hello everyone! I am learning JSP and Java at the moment and wrote a (very) simple guestbook to get started with JSP. But i want to ensure that noone can use CSS, so i need to strip the HTML code before saving it to my mySQL database. I already searched here and found the " PreparedStatement pStmt = conn.prepareStatement("INSERT INTO...

How to start using and developing on Ubuntu Linux?

I am a newbie Linux user who came from 10 years using windows OS, and developing in Microsoft languages. I want to have a good experience in Linux world and developing on it. First, I want to learn how to use this new OS, then how to start developing on it, I am interested in web applications, specially using Java/PHP because I have some...

Getting the inputstream from a classpath resource (XML file)

In Java web application, Suppose if I want to get the InputStream of an XML file, which is placed in the CLASSPATH (i.e. inside the sources folder), how do I do it? ...

How should I resolve java.lang.IllegalArgumentException: protocol = https host = null Exception?

I am working on a SSL client server program and I have to reuse the following method. private boolean postMessage(String message){ try{ String serverURLS = getRecipientURL(message); serverURLS = "https:\\\\abc.my.domain.com:55555\\update"; if (serverURLS != null){ serverURL = new URL(serverURLS); ...

How to instantiate a class that has a constructor requiring an interface object

My java skills are limiting me from doing what I want to do. I am trying to use the Interactive Brokers Java API to see if I can do some algorithmic trading (on paper initially). I want to call a method called ReqMktDepth() which is in a class called EClientSocket. The EClientSocket constructor requires an object of type AnyWrapper to ...

JAX-WS client with AXIS server; namespace problem?

I'm having a problem related to JAX-WS and AXIS. JAX-WS (2.1.7) as a client, Axis (1.4.x) as server. Everything works OK, but the response can't be read to Java. Response: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xm...

Can I guarantee the order in which static initializers are run in Java?

I have a Set class (This is J2ME, so I have limited access to the standard API; just to explain my apparent wheel-reinvention). I am using my set class to create constant sets of things in classes and subclasses. It sort of looks like this... class ParentClass { protected final static Set THE_SET = new Set() {{ add("one"); ...

Can anyone show me a good tutorial of Apache Wicket ?

I want to use apache wicket for pagination but i am not much aware of that . so if anyone can tell me where can i find the examples and tutorials , ...

Overhead of searching and calling a method with reflection

I have a class that should read a message, extract its type from the envelope and then call a method that have to process the message; at each message type is associated an enum member. There are 30+ message types. One way to dispatch the message is to just use a switch, but it's really ugly and error-prone (have I already tract that c...

Get the entity previous version in Hibernate Envers

I have an entity loaded by Hibernate (via EntityManager) User u = em.load(User.class, id) This class is auditaded by Hibernate Envers. I want to load the previous version of this class. How can I do it? Thanks ...

Problem using richfaces to blind up and blind down

Using JSP and RichFaces. The search div should blind up when the "Run Search" button is clicked and the results div should blind down. <div id="paper"> <f:view> <h:form> <div id="criteria"> <rich:panel header="Search"> <h:inputText value="#{Bean.na...

How do I create a bar chart using the Java prefuse library?

I've currently got prefuse to plot a scatter graph, where the X axis is the computer name and the Y axis is its temperature. How do I get it to draw bars showing the values instead of discrete points? I'm currently using the following code to render the points: ShapeAction shape = new ShapeAction(group, Constants.SHAPE_RECTANGLE); Colo...

Faster javac/ant?

I find java starts up and runs practically instantly for me - but javac takes a few seconds, and ant makes it slower again. It's only a few seconds, but my edit-compile-test loop would be smoother without it. :-) BTW: I've already used vim's ":make" with ant. Is there a way to speed up javac and/or ant? I'm thinking of special switc...

Is WEB-INF in the CLASSPATH?

Is the WEB-INF file in the CLASSPATH of a Java Web application? ...

JSP: EL expression is not evaluated

I have a JSP page running on Tomcat 5.5. I have the following code: <c:forEach var="i" begin="1" end="10" step="1"> <c:out value="${i}" /> <br /> </c:forEach> The output I am getting is: ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} I cant work out why the forEach loop is working but the output is not working. Any...

Accessing an Object's attribute value using an expression

Consider the following code: Class Demo { Person person = new Person("foo"); // assume Person class has a 'name' field. //Now, how do I get the value of a field, using some expression. String expression = "person.name"; } Now, I want to evaluate the 'expression' to get the value of the 'name' attribute. Can anyone tell ho...

How to know about OutOfMemory or StackOverflow errors ahead of time

In Java, is there a way to know that a StackOverflow error or OutOfMemory exception may happen soon? The OutOfMemory exception might be an easier one to catch, if one is capable of getting memory usage statistics programmatically, and if one knows ahead of time how much memory needs to be used before the OutOfMemory exception is throw...

A method to reverse effect of java String.split()?

I am looking for a method to combine an array of strings into a delimited String. An opposite to split(). I've seen this in other languages. Wanted to ask the forum before I try writing my own( since the JDK has everything...) Thanks, ...

Java3d Behaviors and movement

I would like to move a sphere in a random direction within a simple universe. How could i achieve this with behaviours by changing the location a small amount frame by frame. The reason I am trying to do this is to produce random movement within the universe and eventually build in simple collision detection between the particles. Any a...

Disable all default HTTP error response content in Tomcat

By default, Tomcat sends some HTML content back to the client if it encounters something like an HTTP 404. I know that via web.xml an <error-page> can be configured to customize this content. However, I'd just like for Tomcat to not send anything in terms of response content (I'd still like the status code, of course). Is there any way ...