Win a copy of Head First Android this week in the Android forum!

Arijit De

Greenhorn
+ Follow
since May 16, 2012
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 Arijit De

Hi,

Can anyone tell me if there is a WYSIWYG editor for JSP with support for Strut2 and Spring MVC support?

Thanks,

Arijit
I have Struts2 web application. There is a FileDownloadAction class that is triggered when a form button is pressed. The file is downloaded properly. But because the application is targeted to users in a rural third world country, where Internet download speed is no more 20 kbps and the Internet connection breaks often and the entire process of file download has to resume from the beginning. Is there a way in Stuts2 or Java EE by means of which the file download upon resumption can start from the point at which the connection broke off.

Please help?
7 years ago
Hi,

I am getting a intermitent nested transaction exception when using hibernate 4.1.3. The error is as follows:

org.hibernate.TransactionException: nested transactions not supported
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152)
org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396)
sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352)
$Proxy63.beginTransaction(Unknown Source)
com.tcs.cto.enable.first.dao.UniversalDao.retrieveByFieldValue(UniversalDao.java:41)
com.tcs.cto.enable.first.dao.UniversalDao.lookup(UniversalDao.java:62)
com.tcs.cto.enable.first.application.EquityInstrumentInformationFactory.createEquityInstrumentInformation(EquityInstrumentInformationFactory.java:32)
com.tcs.cto.enable.first.application.EquityInstrumentInformationFactory.getEquityInstrument(EquityInstrumentInformationFactory.java:27)
com.tcs.cto.enable.first.ipad.ws.organizationdetails.OrganizationDetailsFactory.createOrganizationDetails(OrganizationDetailsFactory.java:25)
com.tcs.cto.enable.first.ipad.ws.organizationdetails.OrganizationDetailsResource.getOrganizationDetails(OrganizationDetailsResource.java:29)
sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)



The problem is I have no nested exception. The exception is thrown once / twice everyday. My universal DAO class looks like this.

public class UniversalDao {

public void update(Object object){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.saveOrUpdate(object);
session.getTransaction().commit();
}

public void add(Object object){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(object);
session.getTransaction().commit();
}

@SuppressWarnings("unchecked")
public List<Object> retrieveAllObjects(String objectName) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("from "+ objectName);
List<Object> objectList = (List<Object>) query.list();
session.getTransaction().commit();
return objectList;
}

@SuppressWarnings("all")
public List retrieveByFieldValue(Class classObject, String propertyName, String propertyValue){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Criteria criteria = session.createCriteria(classObject);
criteria.add(Restrictions.eq(propertyName, propertyValue));
List list = criteria.list();
session.getTransaction().commit();
return list;
}

@SuppressWarnings("all")
public List retrieveByFieldValue(Class classObject, String propertyName, Object propertyValue){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Criteria criteria = session.createCriteria(classObject);
criteria.add(Restrictions.eq(propertyName, propertyValue));
List list = criteria.list();
session.getTransaction().commit();
return list;
}

@SuppressWarnings("all")
public Object lookup(Class classObject, String propertyName, String propertyValue){
List list = retrieveByFieldValue(classObject,propertyName,propertyValue);
Object obj = ( list != null && list.size() > 0 ) ? list.get(0) : null;
return obj;
}

@SuppressWarnings("all")
public Object lookup(Class classObject, String propertyName, Object propertyValue){
List list = retrieveByFieldValue(classObject,propertyName,propertyValue);
Object obj = ( list != null && list.size() > 0 ) ? list.get(0) : null;
return obj;
}

@SuppressWarnings("all")
public void delete(Object object){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.delete(object);
session.getTransaction().commit();
}

public void deleteAll(String objectName){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("delete "+ objectName);
query.executeUpdate();
session.getTransaction().commit();
}

@SuppressWarnings("all")
public List retrieveMax(Class classObject, String propertyName){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Criteria criteria = session.createCriteria(classObject);
criteria.setProjection(Projections.max(propertyName));
List list = criteria.list();
session.getTransaction().commit();
return list;
}

Please help


Can one use struts2 without using the customer tag library. In other words how does one get data from the value stack without tag library.
8 years ago
Hi,

I am maintaining a Java EE 5 application where a .NET .exe file is being run in regular intervals from a thead spawned from a Java Servlet's init( ) method.

Is this acceptable practice? Some red flags jump out
(1) For starters one should not normally tamper with a servlet's init( ) or service( ) methods.
(2) Using a Runtime class instance to run a .exe looks hacky to me.

Am I correct in my understanding? If so what alternatives on how to run .exe file is availaible. Please let me know. Web services comes to mind, but there is nobody at the .net end to create a endpoint.
8 years ago
Ok, how do I fix it. The request is a post.
9 years ago

Read this article and pay particular attention to the PRG pattern. No action should ever be repeatable by simply copying a URL which results in a GET.



I am using a POST request. Not a GET.
9 years ago
Hi,

I am facing a security issue in IE8.

I have to login roles admin and user.

I first login as a admin in login. And then go to another browser window, and then login and as user.

Then I copy the URL from the IE8 address bar for admin login window and paste it to the use login browser window and it automatically logs in as an administrator.

Can you tell me how to fix this issue?

Thanks,
9 years ago
Hemant, Thanks. I guess I had not used versioning.
I was asked the following question at an interview a few days back.

There is a table <EmployeeNo, Salary>. There is an entry ('Emp1', $100).
User A updates the tuple altering salary from $100 to $200.

Later another user B tries to update tuple from $100 to $400.

How can you prevent this?

There is a special feature in hibernate to prevent this doube update. What is it?


I said that if the two users are concurrently trying to update the tuple, then doing updates within a simple transaction would prevent a dirty read.
However, this was not the answer as users A and B were not concurrently updating.

Does anyone have an answer?