java

HTML/JSP Doubt, Print date on webpage...

I made a function which displays date on the webpage,, and i uploaded the same onto some server... But when i changed the date of my system, i noticed that the date is dependent on client machine.. Is it not possible to get the date from actual time server and embed that code into my program.. Hope i am able to explain my doubt.. Ple...

Encrypting sensitive information in JBoss configuration

The standard data source configuration in JBoss requires the username and password of the database user to be in the xxx-ds.xml file. If I define my data source as a c3p0 mbean I encounter the same issue. Is there a standard way to have the user and password encrypted? What is a good place to save the key? This of course relevant to to...

Sending email in Java using Apache Commons email libs

I am using Apache Commons Email library to send emails, but I am not able to send them via GMail SMTP server. Can anyone provide sample code which works with GMail SMTP server and others? I am using the following code which does not work: String[] recipients = {"[email protected]"}; SimpleEmail email = new SimpleEmail(); email.setHos...

Generic return

Hi, there is an immutable class: Scope<Cmp extends Comparable<Cmp>> public Scope<Cmp> crop(Scope<Cmp> scope) { ... return new Scope<Cmp>(starts, ends); } it has many similar methods is extended by: Timerange extends Scope<Date> and many others (also immutable). Id like them to return object of its type. For example: time...

Fetching customer orders: Set<Order> getAllOrders() vs. Set<Integer> getAllOrders()

I haven’t done much Java programming and hence a lot of unanswered ORM questions revolve in my head that might seem as fairly straight forward to more seasoned folks. Let's say we have two classes: Customer and Order. Customer class implements a method called listAllOrders, what should the method’s signature be? Set<Order> getAllOrde...

Java Struts 1: forward from action to action. Passing data through ActionForms

Hi, We've been trying to redirect from one action to another, hoping that data would pass itself from ActionForm to ActionForm. Basically, we have to actions. The first action receives a request from the browser, prints some data field, and forwards it to another action, that prints the same fiend and redirects to a jsp. The thing is th...

Need help with building C# example in ANTLR 2.7

Hi, I need to build the CSHARP V1 example which comes with ANTLR v 2.7.7. Command: D:\Comp\antlr\examples\csharp\csharp_v1>nant I am getting the following output: D:\Comp\antlr\examples\csharp\csharp_v1>D:\Comp\nant\bin\nant NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006) Copyright (C) 2001-2006 Gerry Shaw http://nant.sourcefor...

How to read an external properties file in Maven

Does anyone know how to read a x.properties file in Maven. I know there are ways to use resource filtering to read a properties file and set values from that, but I want a way in my pom.xml like: <properties file="x.properties"> </properties> There was some discussion about this: Maven External Properties ...

Java BBCode library

Has anybody used a good Java implementation of BBCode? I am looking at javabbcode : nothing to see kefir-bb : Listed as alpha BBcode parser in JBoss source code. Are there any better options? ...

Spring MVC DefaultRequestToViewNameTranslator capitalization issue

I'm trying out the whole "convention over configuration" thing with Spring MVC. Spring has all sorts of tools to help with this, and I'm trying some of them out. However, I ran into a problem with our team's configuration not quite matching what Spring wants. The problem is that we take URLs like "http://ourSite/SomePage.do", put them...

Efficient modelling of an MruList in C# or Java

How would you implement a capacity-limited, generic MruList in C# or Java? I want to have a class that represents a most-recently-used cache or list (= MruList). It should be generic, and limited to a capacity (count) specified at instantiation. I'd like the interface to be something like: public interface IMruList<T> { public...

JPanel size by inner components

Is it possible to tell JPanel to set its size to fit all components that it contains? Something like pack() for JFrame. edit: The trick with preferredSize didn't help. I've got JSplitPane, where in one part there is GridBagLayout with many labels (see screenshot) and labels overlap each other. ...

Error in velocity and log4J

Hello, I built a webapp that works perfectly fine in my localhost (tomcat). But when I tried to deploy, velocity crashes in init(), leaving me with this strange stack trace here (sorry for the size): ERROR [main] (VelocityConfigurator.java:62) - Error initializing Velocity! org.apache.velocity.exception.VelocityException: Failed to i...

What's the best way to pass arguments to a tomcat instance?

What's the best way to pass arguments to a tomcat instance? Are command line arguments available to all applications within the container? Can I pass arguments to particular apps? Do I need to manage this through the built in app server? EDIT: To clarify, I'm looking to pass a parameter to specify the configs to use. Sometimes this migh...

JFreeChart Annotations

hi, I'm having trouble understanding how the annotations system works. For example I can draw a vertical line as an annotation using some coordinates I get from the mouse, but I can't draw a line between 2 different points. This works: HighLowRenderer hlr=(HighLowRenderer)plot.getRenderer(); XYLineAnnotation a1=new XYLineAnnotation(...

Large Numbers in Java

How would i go about doing calculations with extremely large numbers in Java? i have tried long but that maxes out at 9223372036854775807, and when using an integer it does not save enough digits and therefore is not accurate enough for what i need. Is there anyway around this? ...

Create Word/RTF file with table of contents from Java

Hi, I want to create a Word or RTF file with a table of contents (with links to each section) from Java. From my understanding, iText & Apache POI do not support generating a table of contents. Some clients of the app still use older versions of Word, so I need a library that supports the older Word doc format. Does anyone know how I ca...

Unable to update snapshots or run the install goal with Maven

Does anyone have an idea how to resolve this Maven error? I get the following when I attempt to update my project's snapshots: Build errors for my-projects-name; org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-dependency-plugin:2.0:u...

Nested prohibit/require operators in Lucene search queries

I am using Lucene for Java, and need to figure out what the engine does when I execute some obscure queries. Take the following query: +(foo -bar) If I use QueryParser to parse the input, I get a BooleanQuery object that looks like this: org.apache.lucene.search.BooleanQuery: org.apache.lucene.search.BooleanClause(required=true,...

Merge Spring and Grails projects

We are developing an backoffice application using Spring and Maven as configuration manager. The project is moreless divided in two parts, and one of this parts is just for manage the data in the DB tables. Now someone has discovered Grails, and with Grails this job is very easy, but we can't drop all the job and start a new project (th...