Juri Glass

Greenhorn
+ Follow
since Jul 01, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juri Glass

MaheshS Kumbhar wrote:Hi

How can we access default variable using object reference variable directly as in following code segment

class abc
{
int i;
public static void main(String[]s)
{
abc a = new abc();
System.out.print(a.i);
}
}



This code compiles and gives you the value of i. Hints:
* Since you don't initialize your variable, it's autoinitialized to 0.
* You are using print. Try using println instead, it appends a newline. You then may see your output.

Best
Juri
14 years ago
Hi

When I do:

resource is null, the Java API says that getResource returns "A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource."

So, how do I determine where the classloader is looking for the resource?

Best
Juri
14 years ago
Hi

I have a maven2 project which builds me a war file to run in a glassfish. Now I want to read from a file located in WEB-INF (can be moved if necessary).

In a servlet I can do:

How to test that with a JUnit 4.7 testcase?
How to refer to the files in WEB-INF in the JUnit tests? How do I set the context?

The maven project has this structure (shortened):

Best Juri

EDIT: Typo
14 years ago
Ok, I removed the

and its working.

But now I have to submit for every instance an id. Nice would be something like:
If no id given, generate one.
Hi

I want to set a auto-incremented key by myself. How to achieve this?

The class looks at the moment like this:


The corresponding field in the database has the auto-increment flag attached.

I am using JPA/Hibernate/MySQL/Tomcat. Btw.: I cannot change the database schema.

Edit:
If I set the id in an instance and commit it, I get this exception:



Hi

I want to initialize some things after tomcat is started.
As far as I know, there are two approaches:

* Write a Servlet and configure it in the web.xml with load-on-startup. But this seems to me like a hack. I want to init some stuff and don't serve someone.

* Add a LifecycleListener. How to configure this? In http://docs.sun.com/source/817-6087/dglfcycl.html#wp16901 is talked about a domain.xml, sometimes about a server.xml. I don't have neither.

Which is the 'right' way?

Best
14 years ago