The problem I am trying to solve is that I want to check all incoming GET urls against a database. If the the url exist in the database it shall be passed to a certein controller. I'm using Spring 3.0.
First I tried to make an interceptor and add that to DefaultAnnotationsHandlerMapping. Turns out i couldn't modify the url in preHandle(...
I have this Swing app I'm working on that has a pair of JSliders and JTextFields that both display & control the value of two numbers. Right now I kind of hacked things together to make it work, intercepting change events and updating the display. However I'm thinking a better way would be to make a model that has the two numbers and som...
I have to access the JSTL variable which is calculated inside the iterator.
Excerpt of code:
<c:forEach var="resultBean" items="${resultList}" varStatus="status">
card: ${resultBean.cardNum}
</c:forEach>
i would like to access ${resultBean.cardNum} in the scriptlet code. what i am doing right now is:
<c:forEach var="resultBe...
I have a class AppUser;
class AppUser {
private String firstName;
private String lastName;
//-- getters and setters
}
I also have another class Student;
class Student {
private AppUser appUser;
private Date dateOfBirth;
//-- getters and setters
}
How would i search for Student John Doe, firstName John, lastName Do...
I'd like to print out all prime numbers from an array with method. I can do it with one int
but don't know how to return certain numbers from array. Thanks for help!
public static boolean isPrime(int [] tab) {
boolean prime = true;
for (int i = 3; i <= Math.sqrt(tab[i]); i += 2)
if (tab[i] % i == 0) {
...
I've a Servlet filter which performs the following type cast:
HttpServletRequest httpRequest = (HttpServletRequest) req;
At present my filter is responsible for two tasks that would be better separated into two filters. If I'd split the logic into two filters I'd need two casts.
What is the performance impact of such a cast? Is it wo...
Hi,
I'm looking for the best way to stream live data over the http protocol with java.
I'm currently using HttpURLConnection to receive json feeds, I would like to know if it can be used to stream feeds too.
...
I've successfully created an item scanner for my game.
Here is my code:
import java.io.*;
import java.util.*;
public class ItemScanner {
public static void main(String args[]) {
System.out.print("Enter item to find: ");
Scanner sc = new Scanner(System.in);
find(sc.nextLine());
}
public static v...
This is a question out of curiousity.
Today I took a look at the implementations of StringBuilder and StringBuffer. Here's the append() method:
public StringBuilder append(String str) {
super.append(str);
return this;
}
AbstractStringBuilder.append(str) also returns this. Are there any benefits of discarding the return value (...
Very often I come across negative feedback on Java Date and other date-time-related classes. Being a .NET developer, I cannot fully (without having used them) understand, what's actually wrong with them.
Can anybody shed some light on this?
...
I am stuck here:
my input file:
123 456 789
872 727 282
123 838 831
818 833 939
Now, I need to save data in a hashmap, 2d array or any best possible alternative like this:
key value
123 -> 456, 789, 838, 831
872 -> 727, 282
818 -> 833, 939
What is the best possible way (simple and optimized) to achieve this and using what?
I a...
In Java or .NET, how would you create a server that listens to a specific port?
(Just a dummy server, I just want to get the high level idea.)
...
The goal is to remove all Dependent when their Owner is deleted. I have the following classes:
@Entity
class Dependent {
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY, optional = false)
@Column(name = "OWNER")
private Owner _owner;
}
@Entity
class Owner {
...
}
In the current implementation Dependen...
the external Application works good in IE so i know the problem is inside My App.
The external web app is java applet and java script based, and the problem im experiensing is when the java applet tryes to run a java script. The Applet opens a seconday window with a java script and tryes to do some operations but then i just stops. And ...
My newest project is able to generate documents with information from a database.
So I copy the document template on demand to an temporary folder for a user and modify it. I do this because every template must be available during modification.
Afterwards the user is awarded with his document via a download link from my webapp.
My que...
hello,
i am looking for some sample code or tutorial that sets up the most basic opengl es application.
for example, just do glClear() in the renderloop.
i have already been searching the web but all i found was either out of date or too much and too complicated.
thanks!
...
Hi
I am profiling a java applet startup time. I have noticed that a huge jar of size 5MB is fully read every time a resource from the jar is requested.
E.g. images log configuration files, I18N files etc....
Sould it behave that way? Is it possible just to jump to the correct point ? Is it possible to read the file only once?
If I will...
I have several Sets that store the objects of the same class, but I want to specify a different identity function for each of them (i.e. say, in one set A==B if A.x==B.x, while in another A==B if A.y==B.y).
Currently I use TreeSets with different Comparators defined for each. I am wondering how the same thing can be done if I want to sw...
A follow up to my Item Scanner, a java tool that scans through a directory of *.txt files.
Thank you all for the help! However now I have a different problem.
When I get the results it reads strings I do not want it to read. How can I block out these strings I do not want it reading?
This is an example what I mean:
Enter item to fin...
Can we manage UDFs, and triggers in Derby database from our own Java Application ?
By managing I mean :
checking if it exists;
adding;
removing.
...