java.lang.OutOfMemoryError: PermGen space

java.lang.OutOfMemoryError: PermGen space

Error:

Solution 1:
1) Go to task manager –>Processes–>close java.exe and then restart glassfish server and run the application

Solution 2:
2) Open domain.xml inside glassfish folder
<jvm-options>-XX:MaxPermSize= 1024 (here change the size or 256 or 1024) this will increase the memory of glassfish and overcomes the error.

Sending Email Using Java

Sending Email Using Java

Here is the code to send email using Java. Here we are going to use gmail gateway to send emails.
Please follow these steps before you use this code:
1. Login your google account
2. In google search, search “Application-specific password”
3. Enter a label for your reference and select “generate password”
4. Copy that password and paste it in code at “//password here” line.

Tested in NetBeans 8.0

 

 

Saving Image in Folder and path in database using Java

Saving Image in Folder and path in database using Java

Here is the code to get the image from the user and store it in a folder and store the image path in Database.

JSP and Servlet
MySql Database
Tested with Netbeans 8.0

Database – create table with name and photourl as fields with datatype varchar().

JSP: (Upload Image)

Servlet: