Mattias Ahlin

Greenhorn
+ Follow
since May 31, 2006
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 Mattias Ahlin

Hi

What he is actally asking for is a way to create a temporary directory, not a temporary file.

I'm also trying to create a temporary directory for a test case but havn't found any info on that. I have found alot of info on how to create temp files though

Does anyone here know how to create a temporary directory?

Best regards,
Mattias
10 years ago
Problem solved

I used:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

instead of:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

which is a older version where expressions weren't allowed.
10 years ago
JSP
Hi

I want a select box to display localized values (the values are: once, daily, weekly). I want these values to be displayed in different languages for different users. I'm already using the fmt tag to display localized messages on the site.

In the resouce file containing the translations I have this (I do of cource have the corresponding files for the other languages):
Global.Frequency.Once=Once
Global.Frequency.Daily=Daily
Global.Frequency.Weekly=Weekly

I've tried something like this (frequencies contains the values: Once, Daily, Weekly). But it failes because the fmt tag doesn't seem to accept expressions in the key. What I'm trying to do is to make the key for the fmt tag "Global.Frequency.Once", "Global.Frequency.Daily", "Global.Frequency.Weekly".



Any suggestions on how to solve something like this would be greatly apprechiated?

Best regards,
Mattias
[ August 26, 2007: Message edited by: Mattias Ahlin ]
10 years ago
JSP
I have a class named FoodListDay which represents all the meals for a day.

The Set foodListMeals is not supposed to contain any null elements. But since the attribute is set through setFoodListMeals I don't know what kind of Set is assigned to foodListMeals. If it is a HashSet for instance, null is a valid element type.

To fix this I introduced one line of code in setFoodListMeals that removes any null elements. But I fear that there might be some threading issues with this approach:

Thread A calls setFoodListMeals with a Set containing a null element. It executes the first line of code (assigns the Set to the attribute foodListMeals). It gets preempted by thread B. Thread B calls getFoodListMeals and gets back the set with the null element.

I'm not sure if making the method setFoodListMeals synchronized would take care of that because I don't completely understand thread/synchronization issues.

If thread B wants to call getFoodListMeals when thread A is executing setFoodListMeals, would making setFoodListMeals synchronized make thread B to wait until thread A is done (even though thread B doesn't try to access the synchronized method)?
Do I perhaps have to synchronize both methods to avoid any thread from accessing getFoodListMeals while another thread is already executing setFoodListMeals?

Hi

I have a class that uses alot of other classes. All these other classes are littered with logging on low levels.

I would like to suppress all logging by setting the default level for the ConsoleHandler to WARNING. Then I want to set the logging level to FINE on my package and only my package. Is that possible?

My logging.properties looks like this (I have verified throught testing that this is the file used by the code):



As you can see, I only use a ConsoleHandler and I'm trying to set all logging to WARNING and then set the level to FINE on my package only.

The problem is that the level WARNING seems to apply on my package to. If I lower "java.util.logging.ConsoleHandler.level" to FINE, my logs are logged to the console but if I raise it to WARNING they are not.

Any suggestions? It seems to me that this should be simple but no matter what I've tried it hasn't worked

I would be thankful for your help.

Best regards,
Mattias
11 years ago
This is how I solved the problem:
11 years ago
How do you want to compare the dates? Do you want to check if one is befor the other in time, if they are equal or what?
11 years ago
Hi

I want to print out a chinese character. This is the code I'm using, but it doesn't work. Any ideas why?
11 years ago
But normally you don't declare your RuntimeExceptions in the method header. Instead you declare them in the method's javadoc. See java.util.Vector for instance:


Otherwise your API will be polluted with RuntimeExceptions that the clients of the API normally shouldn't be catching anyway.
[ November 28, 2006: Message edited by: Mattias Ahlin ]
11 years ago
Modify your code like this and it'll work:


[ November 28, 2006: Message edited by: Mattias Ahlin ]
11 years ago
The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).

You're right that is can store 9223372036854775807 different numbers. Since half of them are negative, only half of them can be positive.
11 years ago