How to force browser to download file?

You are setting the response headers after writing the contents of the file to the output stream. This is quite late in the response lifecycle to be setting headers. The correct sequence of operations should be to set the headers first, and then write the contents of the file to the servlet’s outputstream. Therefore, your … Read more

Class vs package vs module vs component vs container vs service vs platform in Java world [closed]

class A class is the blueprint for creating objects in class-based object-oriented programming; you should learn the basics of OOP and understand what an object is, what a class is, what is inheritance, polymorphism, encapsulation before learning anything else about Java. package A package is a namespace; it let’s you handle naming conflicts. It basically … Read more

Deleted object would be re-saved by cascade (remove deleted object from associations)

The solution is to do exactly what the exception message tells you: Caused by: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations) Remove the deleted object from an associations (sets, lists, or maps) that it is in. In particular, i suspect, from PlayList.PlaylistadMaps. It’s not enough to just delete the … Read more

Hot deploy on JBoss – how do I make JBoss “see” the change?

I had the same problem in my bundle: (Eclipse IDE + JBoss server adapter) + JBoss AS 7.0.1 (community project). My solution is very simple – you should go to JBoss administrative panel (by default localhost:9990), there in profile settings open Core – Deployment Scanners. Turn on Autodeploy-Exploded (set to true), and by your wishes … Read more

How to implement “Stay Logged In” when user login in to the web application

Java EE 8 and up If you’re on Java EE 8 or newer, put @RememberMe on a custom HttpAuthenticationMechanism along with a RememberMeIdentityStore. @ApplicationScoped @AutoApplySession @RememberMe public class CustomAuthenticationMechanism implements HttpAuthenticationMechanism { @Inject private IdentityStore identityStore; @Override public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext context) { Credential credential = context.getAuthParameters().getCredential(); if (credential != null) { … Read more

Where to find all available Java mail properties?

In the api is a reference to the properties for the specific sun protocol providers. Not sure if you were looking for these: https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html https://javaee.github.io/javamail/docs/api/com/sun/mail/pop3/package-summary.html https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html These are also set on the session object but you use them on your own risk since in other mail implementations they are maybe not supported or they change … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)