java

How to Decode base 64 data

I have an XML doucment in which there is an tag for image like this if there is an image then the tag would be as follows <thumbnail> <type>IMAGE JPG</type> <data> base64 data </data> </thumbnail> And if there is no image then <thumbnail/> I want to get the base64 encoded image using DOM parser and how to handle tags which don't...

Is it safe to use java.util.Timer inside servlet ?

Hi all, for many reasons, it is not good practice to use threads inside servlet. java.util.Timer seems like wrapper to threads. so also it is not safe to use it ? if yes, what is the safest way to schedule task in servlet ? thanks,,, ...

Copy folder and its files to another location

I want to copy F:\test to folder F:\123 so that I have folder F:\123\test. In test folder I hava 2 files: input and output.java But I can not do that erro is: F\123\test\output.java (The system cannot find the path specified) Here is my code: Constant.fromPath = "F:\\test" Constant.toPath = "F\\123\\test"; File source = ne...

Memory address of variables in Java

Please look at the picture below. When we create an object in java with new keyword, we are getting a memory address from the OS. I wonder that, when we write out.println(objName) we can see some strings as output. what is this output? If it is memory address which given by OS to us: a) How can i convert this string to binary? b) How ...

Spring Security basics

How to make a link visible only if an authenticated user has correspondent permissions? I'm using JSF, and as I understand, I should use rendered attribute of a component which should call backing bean's boolean method. I've even found correspondent code some time ago but now I can't find it again. So, can anyone give me an example of...

understand spring xml annotation metadata?

<context:annotation-config/> <context:component-scan... this is used for class that i need to annotated with @Repository @Service @Component... <context:spring-configured /> <context:component-scan... use if i need to use @Configurable <tx:annotation-driven transaction-manager="transactionManager" /> <context:component-sc...

grabbing image from url in google app engine, java

Hey guys; I have a url which leads to in image. How do i grab this image from this url into my servlet? NOTE: the web-app is deployed on google app engine. java.net.URL myURL = "http://a3.twimg.com/profile_images/150131301/slogo4_normal.jpg"; //code to grab the image Thank you ...

Problem in the GetDeclaredMethods (java)

hello to all I have a small problem in my code I have 2 classes public class A { public A foo(int a) {return new A();} } public class B extends A{ public B foo(int x){ return new B();} } now in my code I want to print only the method that was declared in class B in this way B b = new B(); Method[] m = b.getClass().ge...

spring multiple @transactional datasource

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="data.emf" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="transactionManager2" class="org.springframework.orm.jpa.JpaTransactionManager"> ...

Generate well formatted JavaScript

I'm generating huge amount of JavaScript(on server side, ExtJS code) and for debug purposes(mainly,since for production I will -probably - minify the code) it would be nice to have well formatted JavaScript code. Anybody know a library which offer such support? Thanks. Edit 1: What I'm looking for is a Java library which will : lay...

Does anybody recognize any pattern/antipattern in attached class diagram?

Short description: I have a doubt whether it's normal that AbstractCrudDaoImpl implements both interface and abstract class which are inherited from the same parent (ReadOnlyDao). ...

Dynamic Java Compilation: BeanShell, Janino, JavaCompiler?

I am about to start developing a small Java desktop app. The app is just an engine for which the user provides Java classes to do the work (translating input to output). I would like the user to provide actual Java classes as files that can be loaded (and reloaded) on the fly. For this particular use, is there any reason why Java woul...

How to configure transaction management for working with 2 different db in Spring?

I have 2 databases (MySql and HSQLDB). I configured 2 data sources and 2 EntityManagerFactory beans. I can also configure 2 correspondent JpaTransactionManager beans. But I don't know how to specify which of them should be used to manage transactions for concrete service-class. I want to use @Transactional annotation for that purpose, ...

Open source product similar to Rational Software Architect

Hi, Please let me know open source product similar to rational software architect which automatically generates java base classes on completion of design. Thanks in advance. ...

Organizing Java projects

Hello, I'm a junior developer and recently started working for a very small office where they do a lot of in-house development. I have never worked in a project that involved more than one developer or were as big and complex as these ones. The problem is that they don't use all the tools available (version control, automated building,...

mouseListeners and JLabels using images with transparent pixels.

Hi, I'm willing to make a isometric game but I'm having hard time with the mouseListener. I'm using Swing and make losanges by using square images with transparent pixels (GIF format). The problem is that making losanges touch each other edge means having the transparent pixels of one on the top of the others, which is a problem with ...

Why Isn't My Class Reloading?

I know I'm missing something basic. I'm trying to dynamically compile a class and then reload it after a change. The following code works. However, when I call it twice (once after changing the .java), the class definition does not update. What am I missing? File file = new File("/eraseme/Eraseme.java"); File[] files = new File[] {file}...

Porting a servlet to a web service - accessing the context?

Consider a simply servlet: // MyServlet.java protected void doGet(HttpServletRequest request, HttpServletResponse response) { UtilClass.doSomething(getServletContext().getRealPath(SOME_FILE)); } And the utility class does something with the file: // UtilClass.java public String doSomething(String filePath) { File f = new File...

How do I delete the last character of a particular String in Java?

For example I'm extracting a text String from a text file and I need those words to form an array. However, when I do all that some words end with comma (,) or a full stop (.) or even have brackets attached to them (which is all perfectly normal). What I want to do is to get rid of those characters. I've been trying to do that using tho...

Java Scanner with empty delimiter

I'd like to parse some text using an hand-written descending parser. I used Scanner with the following delimiter : "\\s*". Unfortunately, the fact that this pattern matches an empty String seems to make every hasNextFoo and nextFoo matching nothing anymore. The doc doesn't say anything about possibly empty delimitors. ...