java

Which Tomcat 5 context file takes precedence?

Tomcat documentation says: The locations for Context Descriptors are; $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml $CATALINA_HOME/webapps/[webappname]/META-INF/context.xml On my server, I have at least 3 files floating around: 1 ...tomcat/conf/context.xml 2 ...tomcat/Catalina/localhost/myapp.xml 3 ...tomcat/webapps/myapp/...

How to send html email to outlook from Java

I'm trying to send an email in html format using JavaMail but it always seems to only display as a text email in Outlook. Here is my code: try { Properties props = System.getProperties(); props.put("mail.smtp.host", mailserver); props.put("mail.smtp.from", fromEmail); props.put("mail.smtp.auth", authentication); p...

Deploying Web Apps as war Files

I'm having some trouble uploading and getting my web app on the net with my chosen host. I built a war file in Net Beans and asked my host to deploy it for me. This worked fine but to access it I had to point my browser to: www.myDomain.co.uk/explodedWar What of course I wanted was to be able to access it just by pointing my browser ...

Matching inexact company names in Java

I have a database of companies. My application receives data that references a company by name, but the name may not exactly match the value in the database. I need to match the incoming data to the company it refers to. For instance, my database might contain a company with name "A. B. Widgets & Co Ltd." while my incoming data might re...

Servlet being called twice!

Hi there, sorry but I do not have the actual code with me, but I will try to explain: I have a servlet mapped to the following: /admin/* So, this goes to a servlet: public class AdminController extends MainController { public void doPost(HttpServletRequest request, HttpServletResponse response) { // Do stuf here } ...

When to use LinkedList<> over ArrayList<>?

I've always been one to simply use List<String> names = new ArrayList<String>(); I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code. When should LinkedList be used over ArrayList and vice-versa? ...

Retain precision with Doubles in java.

public class doublePrecision { public static void main(String[] args) { double total = 0; total += 5.6; total += 5.8; System.out.println(total); } } Which returns 11.399999999999 Okay clarifying the question a bit, how would i get this to just print (or be able to use it as) 11.4? ...

How to use Java to edit a template document (form letter) from a file?

I'm playing with Java for the first time and need to be able to replace some words in a template. example template - "Dear PUT_THEIR_NAME_HERE, I'm contacting you ..... bla bla bla Regards, PUT_COMPANY_NAME_HERE" What's the simplest way (preferably using the standard library) to make a copy of this template file and add the correct...

Insert a dependent jar into an installer jar

I have a multi-module maven project with an installer sub-project. The installer will be distributed as an executable JAR. It will setup the DB and extract the WAR file to the app server. I would like to use maven to assemble this jar like so: /META-INF/MANIFEST.MF /com/example/installer/Installer.class /com/example/installer/......

Java: Retrive this for methods above in the stack

How would you get a reference to an executing class several stack frames abouve the current one? For example, if you have: Class a { foo() { new b().bar(); } } Class b { bar() { ... } } Is there a way to get the value that would be retrieved by using 'this' in foo() while the thread is executing bar...

Need for Abstract Class as well as Interface?

An interface is a 100% abstract class, so we can use an interface for efficient programming. Is there any situation where an abstract class is better than an interface? ...

How to programmatically add portlet to the JBoss Portal dashboard

How can I programmatically add portlet to the JBoss Portal dashboard of specific user? Is there any remote API of the JBoss Portal to do this? SOAP web service, may be MBean-based API? Of course, as a last resort I can implement such service myself and deploy it to the JBoss Portal, but ideally it should not require deploying anything to...

Using javax.naming.spi.DirObjectFactory to lookup objects from an LDAP

I've implemented an object factory to lookup LDAP objects, but the supplied context does not return the DN (via nameCtx.getNameInNamespace()) from the LDAP. Am i doing it wrong in some way? public class LdapPersonFactory implements DirObjectFactory { @Override public Object getObjectInstance(Object obj, Name name, Contex...

Datatype of SUM result in MySQL

I'm having a bit of a problem with converting the result of a MySQL query to a Java class when using SUM. When performing a simple SUM in MySQL SELECT SUM(price) FROM cakes WHERE ingredient = 'chocolate'; with price being an integer, it appears that the SUM sometimes returns a string and sometimes an integer, depending on the version...

Apache beehive and localizing default pager for DataGrid

I am trying to localize strings created by Apache Beehive and netui default pager. I'd like to translate language of this output. Page 1 of 3 First / Previous Next / Last My .jsp code looks something like this <netui-data:dataGrid name="searchResultsGrid" dataSource="pageInput.someData"> <netui-data:header> ... </net...

Is an SCJP certificate worthwhile?

The SCJP exam tests only the concepts of java and not the programming ability of the individual in java. A person who scores more in SCJP may have less problem solving skills. In real-life programming, both java skills and programming skills should play equal parts. So can we say that someone who holds a SCJP certificate is fit to do rea...

Querying data from Oracle database using java servlet with Netbeans.

From index.jsp code, statement.executeQuery("select * from fus where tester_num like 'hf60' ") ; Example I want "hf60" to be a variable(userinput), wherein USER must input/write data from input text then submit and get the data so that the result will be ("select * from fus where tester_num like 'userinput' "). Where should I insert th...

Hibernate and Oracle native functions

I have an entity that maps to an external oracle table which is one of the primary data sources of my application. This entity is modelled using hibernate. The oracle table now has a complex function defined the calculates some special values. I need to call this funtion somehow - almost as another accessor on the entity. What would yo...

How to generate running time graph for my Java program

Hi I want to generate running time graphs on my java program. Is there any program which makes it? ...

How to analyse .exe parameters inside the program?

I have a program that can have a lot of parameters (we have over +30 differents options). Example: myProgram.exe -t alpha 1 -prod 1 2 -sleep 200 This is 3 Commands (from command pattern object at the end) that each contain some parameters. Inside the code we parse all command (start with -) and get a list of string (split all space) fo...