java

JSP programmatically render

I need programmaticaly render JSP page. As far as I understand JSP should have some compiler. The question is can I use this compiller dirrectly without JspServlet and others? All I need is documentation how to use JSP compiler (Jasper, for example). Some additional information would clarify situation, I think. I can not use standart Js...

Is there an easier way to parse XML in Java?

I'm trying to figure out how to parse some XML (for an Android app), and it seems pretty ridiculous how difficult it is to do in Java. It seems like it requires creating an XML handler which has various callbacks (startElement, endElement, and so on), and you have to then take care of changing all this data into objects. Something like t...

Handle uninitialized parameters in java?

I'm calling a Java method from another language (R). Some of the parameters are optional in my R function. What's the best way to handle uninitialized parameters in a Java method? (Ideally without using exception handling...) Edit: Follow-up based on the first response: "2.Initialize with predefinied defaults and continue" How can...

How can Java inline over virtual function boundaries?

Hi all, I'm reading up some material on whether Java can be faster than C++, and came across the following quote: "Java can be faster than C++ because JITs can inline over virtual function boundaries." (http://www.jelovic.com/articles/why%5Fjava%5Fis%5Fslow.htm) What does this mean? Does it mean that the JIT can inline virtual functi...

Iterative Cartesian Product in Java

Hi, I want to compute the cartesian product of an arbitrary number of nonempty sets in Java. I've wrote that iterative code... public static <T> List<Set<T>> cartesianProduct(List<Set<T>> list) { List<Iterator<T>> iterators = new ArrayList<Iterator<T>>(list.size()); List<T> elements = new ArrayList<T>(list.size()); List<Set<T>> toR...

Socket Programming -Java - Many Clients One Socket Question(s)

Essentially Im trying to get many many java clients connect to a socket on my ColdFusion server (Using the Socket Gateway). However before i even start to code this, Im a little confused about sockets and their performance. First of all, are sockets meant for many(1000+) clients connecting to one socket (say port 2202) on one server? How...

how to reference an external jar in jsp app?

I am new to Eclipse. I am trying to run a jsp example using iText to generate a PDF, I put iText.jar file in Referense Library folder, but when I ran the jsp, I got error message that the class Document defined in the iText,jar can't not be resolved. ...

Best approach to parse text files that contain multiple types of delimiters?

I need to parse some text files that have different types of delimiters (tildes, spaces, commas, pipes, caret characters). There is also a different order of elements depending on what the delimiter is, e.g: comma: A, B, C, D, E caret: B, C, A, E, D tilde: C, A, B, D, E The delimiter is the same within the file but different from one...

Elegant ways to separate configuration from WAR in Tomcat

I am trying to find the best way to pass complex configurations in a Spring webapp running in Tomcat. Currently I use JNDI to pass data sources and strings from the Tomcat context into the webapp, and this works well. But, lets say I need to select the implementation of a notification service. There is no way that Spring can conditiona...

How to read the user or identifier supplied in ws-security

I am using latest Apache CXF to create a webservice. I have configured ws-security using org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor. In my passwordCallbackClass I can access the user or identifier by calling getIdentifier() method of org.apache.ws.security.WSPasswordCallback class. I am also using spring for the whole setup. I...

communication between Java and C#

Hi, I found out that there is a .Net toolkit called GCT - Group Communication Toolkit that is the C# version of JGroup. I want to know whether this and JGroup can be connected together to make java and C# clients communicate with each other. If not, what would be the best option to make a java program and a C# program communicate? One ot...

com iplanet ias JAR

I've been struggling with this for past couple of days. I am trying to test a DAO outside the container but while running the test case I am getting the error: Error creating bean with name 'SqlMapClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.l...

Print number in words

Hi, I am trying code to print a three digit number in words. But this isn't working if first two digits from right are between 11 & 19 (both including). Any help? package com; import java.util.Stack; public class TestMain { public static void main(String[] args) { Integer i=512; int temp =i;int pos=1; Stack<String> stack=new Stack<...

How to get the corresponding file extension if the mimeType of the file is known

When coding in java, How to get the corresponding file extension if the mimeType of the file is known? ...

java.util.regex - importance of Pattern.compile()?

What is the importance of Pattern.compile() method? Why do I need to compile the regex string before getting the Matcher object? for example : String regex = "((\\S+)\\s*some\\s*"; Pattern pattern = Pattern.compile(regex); // why i need to compile Matcher matcher = pattern.matcher(text); // ...

How to pass an object to a class so that when the object updates outside the class, it outdates in it too? (Java)

I'm having a hard time figuring out how to pass by reference in Java. I currently have a class as follows class Example { ArrayList<Foo> list; Bar hello; Example(ArrayList<foo> list, Bar hello) { this.list = list; this.hello = hello; } } In my main class, I initialize an array list of Foo, and a Bar ob...

resize problem with JList?

Hi, i am having resizing problem with JList ... Below is my code ...my requirement is to add a JList with some fixed size into a Panel and when i maximize/minimize the Frame the JList should increase/decrease accordingly .please help me ..how to achieve this? Following is the design: Hi Carl , It works in simple cases but not in the a...

Swing Toolbar placement

I want to display a JToolbar within right side of a split pane, which is also going to contain a JTabbedPane, how can we do that ? wrap TabbedPane and toolbar in some component? ps: user should not be able to minimize, etc in right side pane... ...

web.xml - Java Servlet Filters - Not being run before processing the JSP page (on Tomcat)

I am fairly new to Servlet Filters and have basically joined a project using them and added an additional filter to the web.xml file (deployed on Tomcat 5.5). I am 95% sure that at some point it was working correctly but now when debugging if I put breakpoints at the top of the JSP page I am trying to view (login.jsp), it's template pa...

Hibernate: how do I retrieve my entities from a ScrollableResults?

I do a query that returns a list of entities. How can I retrieve the entities from a ScrollableResults: Session s = ....; Query q = s.createQuery("....") # returns 100000s rows ScrollableResults sr = q.scroll(); sr.scroll(45999); # just a number Employee employee = ??? How do I get an employee in the last line of code ...