MailSending Injava
import java.util.Date;
import java.util.Properties;
import com.sun.mail.smtp.SMTPTransport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
*
* @author arnab chowdhury
*/
public class SendMail
{
SendMail( String to, String message,String subject,String User)
{
String from =User;
String mailhost = "smtp.gmail.com"; //it is googles mail host use proper mail host for proper server
String user = "authenticator@gmail.com"; ///authentication mail id
String password = "authenticator"; //password
boolean auth = true;
boolean ssl = true;//make it false if server is not SSL enabled
Properties props = System.getProperties();
if (mailhost != null) {
props.put("mail.smtp.host", mailhost);
}
if (auth) {
props.put("mail.smtp.auth", "true");
}
javax.mail.Session session = javax.mail.Session.getInstance(props, null);
javax.mail.Message msg = new MimeMessage(session);
try {
msg.setFrom(new InternetAddress(from));
msg.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(message);
SMTPTransport t = (SMTPTransport)session.getTransport(ssl ? "smtps" : "smtp");
try {
if (auth) {
t.connect(mailhost, user, password);
} else {
t.connect();
}
t.sendMessage(msg, msg.getAllRecipients());
}
catch(Exception e)
{
System.out.println(e.toString());
}
finally {
t.close();
}
System.out.println("message Send");
} catch (Exception e)
{
System.out.println(e.toString());
}
}
public static void main(String Ar[])
{
new SendMail("recever@gmail.com", "msgbody", "subject", "sender") ;//edit this parameters properly
}
}
Search Your Question
Saturday, November 15, 2008
BATCH FILE TO LOCK A FOLDER
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo stuff by satish
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==kamal goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo stuff by satish
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==kamal goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
Two methods that you can use to prevent users from connecting to a USB storage device.
To Disable the Use of USB Storage Devices
To disable the use of USB storage devices, use one or more of the following procedures, as appropriate to your situation:
If a USB Storage Device Is Not Already Installed on the Computer
If a USB storage device is not already installed on the computer, assign the user or the group Deny permissions to the following files:
• %SystemRoot%\Inf\Usbstor.pnf
• %SystemRoot%\Inf\Usbstor.inf
When you do so, users cannot install a USB storage device on the computer. To assign a user or group Deny permissions to the Usbstor.pnf and Usbstor.inf files, follow these steps:
1. Start Windows Explorer, and then locate the %SystemRoot%\Inf folder.
2. Right-click the Usbstor.pnf file, and then click Properties.
3. Click the Security tab.
4. In the Group or user names list, click the user or group that you want to set Deny permissions for.
5. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.
Note In addition, add the System account to the Deny list.
6. Right-click the Usbstor.inf file, and then click Properties.
7. Click the Security tab.
8. In the Group or user names list, click the user or group that you want to set Deny permissions for.
9. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.
If a USB Storage Device Is Already Installed on the Computer
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
If a USB storage device is already installed on the computer, set the Start value in the following registry key to 4:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
When you do so, the USB storage device does not work when the user connects the device to the computer. To set the Start value, follow these steps:
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. Locate, and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
4. In the right pane, double-click Start.
5. In the Value data box, type 4, click Hexadecimal (if it is not already selected), and then click OK.
6. Quit Registry Editor.
To disable the use of USB storage devices, use one or more of the following procedures, as appropriate to your situation:
If a USB Storage Device Is Not Already Installed on the Computer
If a USB storage device is not already installed on the computer, assign the user or the group Deny permissions to the following files:
• %SystemRoot%\Inf\Usbstor.pnf
• %SystemRoot%\Inf\Usbstor.inf
When you do so, users cannot install a USB storage device on the computer. To assign a user or group Deny permissions to the Usbstor.pnf and Usbstor.inf files, follow these steps:
1. Start Windows Explorer, and then locate the %SystemRoot%\Inf folder.
2. Right-click the Usbstor.pnf file, and then click Properties.
3. Click the Security tab.
4. In the Group or user names list, click the user or group that you want to set Deny permissions for.
5. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.
Note In addition, add the System account to the Deny list.
6. Right-click the Usbstor.inf file, and then click Properties.
7. Click the Security tab.
8. In the Group or user names list, click the user or group that you want to set Deny permissions for.
9. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.
If a USB Storage Device Is Already Installed on the Computer
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
If a USB storage device is already installed on the computer, set the Start value in the following registry key to 4:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
When you do so, the USB storage device does not work when the user connects the device to the computer. To set the Start value, follow these steps:
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. Locate, and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
4. In the right pane, double-click Start.
5. In the Value data box, type 4, click Hexadecimal (if it is not already selected), and then click OK.
6. Quit Registry Editor.
Thursday, November 13, 2008
Stop Back Button in JSP
response.addHeader( "Cache-Control", "max-age = 0, s-maxage = 0,must-revalidate, proxy-revalidate, no-cache, no-store ");
response.addHeader( "Pragma", "no-cache");
response.addHeader( "Pragma", "no-cache");
JSTL Mapping in web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
</web-app>
Take the jstl.jar and standard.jar from
Apache Tomcat 6.0.16\webapps\examples\WEB-INF\lib
and paste in your WEB-INF\lib folder.
Subscribe to:
Posts (Atom)