Search This Blog

Friday 6 December 2013

Sending email through JavaMail API in Servlet

The JavaMail API provides many classes that can be used to send email from java. The javax.mail and javax.mail.internet packages contains all the classes required for sending and receiving emails.
For better understanding of this example click steps for sending email from javamail api
For sending the email using JavaMail API, you need to load the two jar files:
  • mail.jar
  • activation.jar
download these jar files or go to the Oracle site to download the latest version.

Example of Sending email through JavaMail API in Servlet

Here is the simple example of sending email from servlet. For this example we are creating 3 files:
  • index.html file for input
  • SendMail.java , a servlet file for handling the request and providing the response to the user. It uses the send method of Mailer class to send the email.
  • Mailer.java , a java class that contains send method to send the emails to the mentioned recipient.

index.html
  1. <form action="servlet/SendMail">  
  2. To:<input type="text" name="to"/><br/>  
  3. Subject:<input type="text" name="subject"><br/>  
  4. Text:<textarea rows="10" cols="70" name="msg"></textarea><br/>  
  5. <input type="submit" value="send"/>  
  6. </form>  

SendMail.java
  1. import java.io.IOException;  
  2. import java.io.PrintWriter;  
  3.   
  4. import javax.servlet.ServletException;  
  5. import javax.servlet.http.HttpServlet;  
  6. import javax.servlet.http.HttpServletRequest;  
  7. import javax.servlet.http.HttpServletResponse;  
  8.   
  9.   
  10. public class SendMail extends HttpServlet {  
  11. public void doGet(HttpServletRequest request,  
  12.  HttpServletResponse response)  
  13.     throws ServletException, IOException {  
  14.   
  15.     response.setContentType("text/html");  
  16.     PrintWriter out = response.getWriter();  
  17.       
  18.     String to=request.getParameter("to");  
  19.     String subject=request.getParameter("subject");  
  20.     String msg=request.getParameter("msg");  
  21.           
  22.     Mailer.send(to, subject, msg);  
  23.     out.print("message has been sent successfully");  
  24.     out.close();  
  25.     }  
  26.   
  27. }  

Mailer.java
  1. import java.util.Properties;  
  2.   
  3. import javax.mail.*;  
  4. import javax.mail.internet.InternetAddress;  
  5. import javax.mail.internet.MimeMessage;  
  6.   
  7. public class Mailer {  
  8. public static void send(String to,String subject,String msg){  
  9.   
  10. final String user="sonoojaiswal@javatpoint.com";//change accordingly  
  11. final String pass="xxxxx";  
  12.   
  13. //1st step) Get the session object    
  14. Properties props = new Properties();  
  15. props.put("mail.smtp.host""mail.javatpoint.com");//change accordingly  
  16. props.put("mail.smtp.auth""true");  
  17.   
  18. Session session = Session.getDefaultInstance(props,  
  19.  new javax.mail.Authenticator() {  
  20.   protected PasswordAuthentication getPasswordAuthentication() {  
  21.    return new PasswordAuthentication(user,pass);  
  22.    }  
  23. });  
  24. //2nd step)compose message  
  25. try {  
  26.  MimeMessage message = new MimeMessage(session);  
  27.  message.setFrom(new InternetAddress(user));  
  28.  message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));  
  29.  message.setSubject(subject);  
  30.  message.setText(msg);  
  31.    
  32.  //3rd step)send message  
  33.  Transport.send(message);  
  34.   
  35.  System.out.println("Done");  
  36.   
  37.  } catch (MessagingException e) {  
  38.     throw new RuntimeException(e);  
  39.  }  
  40.       
  41. }  
  42. }  

Introduction Of Servlet

 Servlet ......


Servlet technology is used to create web application (resides at server side and generates dynamic web page).
Servet technology is robust and scalable as it uses the java language. Before Servlet, CGI (Common Gateway Interface) scripting language was used as a server-side programming language. But there were many disadvantages of this technology. We have discussed these disadvantages below.
There are many interfaces and classes in the servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest, ServletResponse etc.

What is a Servlet?

Servlet can be described in many ways, depending on the context.
  • Servlet is a technology i.e. used to create web application.
  • Servlet is an API that provides many interfaces and classes including documentations.
  • Servlet is an interface that must be implemented for creating any servlet.
  • Servlet is a class that extend the capabilities of the servers and respond to the incoming request. It can respond to any type of requests.
  • Servlet is a web component that is deployed on the server to create dynamic web page.
servlet

Advantage of Servlet

advantage of servlet
There are many advantages of Servlet over CGI. The web container creates threads for handling the multiple requests to the servlet. Threads have a lot of benefits over the Processes such as they share a common memory area, lighweight, cost of communication between the threads are low. The basic benefits of servlet are as follows:
  1. better performance: because it creates a thread for each request not process.
  2. Portability: because it uses java language.
  3. Robust: Servlets are managed by JVM so no need to worry about momory leak, garbage collection etc.
  4. Secure: because it uses java language..

Friday 2 August 2013

Google Search Tricks

Google Search Tricks:
Well let me tell You what actually google tricks mean. Google tricks/google tips, does not mean hacking google, Using the below Google operators, we can get the desired google result very quickly. Well we can name this as hidden google secrets or Advanced google searching.                              .                                                                 Google Search Tricks tips
Google Trick -1 :- GOOGLE OPERATOR
Type the following highlited words in google search box.
Google has several google operators that can help you find specific information, specific websites or inquire about the indexing of your own   site, below you will find the most important ones:                                                            
Click on the example google trick, and You will be redirected to google.
define: - This google operator will find definitions for a certain term or  word over the Internet. Very useful when you come across a strange word when writing a post. I use this as a google dictionary. example : (define computer)
info: - The google info operator will list the sets of information that    Google has from a specific website (i.e. info:http://hack2007.50webs.com)
site: - This google operator can be used to see the number of indexed     pages on your site (i.e.site:www.hack2007.50webs.com).                  Alternative it can also be used to search for information inside a specific        site or class of sites.
link: - This google link operator allows you to find backlinks pointing         to your site. Unfortunately the count is not updated frequently and             not all backlinks are shown
allinurl: - Using this Google operator will limit the search to results         that contain the desired keywords on the URL structure. (i.e. allinurl:dailyblogtips)
fileformat: - Useful Google operator for finding specific file formats. Sometimes you know that the information you are looking for is likely to be contained in a PDF document or on a PowerPoint presentation, for instance. (i.e. “fileformat:.pdf market research” will search for PDF documents that contain the terms “market” and “research”)

Google trick -2 Top 10 Cool Google Search Tricks

well as we have gained enough knowledge regarding google operators, lets have a look at the following 10 cool google search tricks. Click on the example google trick, and You will be redirected to google.
  1. Google trick to  search different file formats (keyword filetype:doc)
  2. Google trick to search educational resources (keyword site:.edu) example (computer site:.edu)
  3. Finding the time of any location (time romania)
  4. Finding the weather of any location (boston weather)
  5. Tracking commentary of live events (Olympic games Beijing 2008)
  6. Using Google as a calculator (9 * 10)(143+234)(119-8)
  7. Converting currencies (1 USD in INR)(10 US Dollars in Indian Rupee)
  8. Find how many teaspoons are in a quarter cup (quarter cup in teaspoons)
  9. how many seconds there are in a year (seconds in a year)
  10. Tracking stocks (stocks:MSFT)
  11. Finding faces (add imgtype=face to the URL)
google trick -3 Top Essential Google Search shortcuts

#1: Get Local Weather

Type: “weather [city name or zip/postal code]”                                                                     Example: “weather 500054″ or “weather boston”

#2: Check Flight Status

Google automagically pulls flight data from FlightStats.com. All you have to do is enter the flight number.                                                                                                                                                           Type: [flight name and/or number]                                                                                     Example: “bc254″ or “newyork21″

#3: Convert Distances

Type: “[value] [first distance unit] to [second distance unit]”                                              Example: “100 kilometers to miles”

#4: Find a Phone Number

Find a Person:

    Type: “[person’s name], [city or zip/postal code]”                                                           Example: “john smith, london”

Find a Business/store:

    Type: “[business name or type], [city or zip/postal code]”                                         Example: “book store, boston”
Google trick -4 :Google search trick for Rapidshare files search:
#1 site:rapidshare.com inurl:users "*"

#2 site:rapidshare.de inurl:users "*"

#3 site:rapidshare.com inurl:files "*"

#4 site:rapidshare.de inurl:files "*"

#5 site:rapidshare.com inurl:users (pass|password)
#6 site:rapidshare.de inurl:users (pass|password)

Suppose u need some info on ebooks. Then u can try following keyword to see all rapidshare folders having any hacking related thing in it

site:rapidshare.com inurl:users "ebooks"

Hiding Disk Completley

The following trick will enable you to hide any volume or disk you want for the sake of your privacy:-



follow the given steps :-
1. click on start.
2. select run.
3.Now type cmd.

(this will open a command prompt)
4.type the command DISKPART
5.now type LIST VOLUME
6.now we have to select the drive we want to hide
for example : SELECT VOLUME 3
7. type the command now REMOVE LETTER E
(as in case of volume 3)

Boom .
the volume will become invisible when you restart your computer.

To get the volume back to visible state.
follow the steps 1 to 6 again :
and in the 7th step write ASSIGN instead of REMOVE

I tried this on Window7- 32 bit OS

Friday 19 July 2013

Click here to download BSCIT sem V and VI Syllabus



Click here to download BSCIT sem V and VI Syllabus
Semester V

USIT501 Network Security
USIT502 Asp.Net With C#
USIT503 Software Testing
USIT504 Advanced Java
USIT505 Linux Administration
Semester VI

USIT601 Internet Technology
USIT602 Project Management
Studies
USIT603 Data Warehousing
USIT607 Project Report
USIT608 Project Viva Voce
Elective
USIT604 IPR and Cyber Laws
Studies
USIT605 Digital Signal And Systems

USIT606 Geographic Information

Geographic Information
Systems Practical


Click here to Download the Syllabus

How to declare keyword as a variable.....??

IN java Programming language you can declare a keyword or literal as variable prefixing keyword with $ symbol

For ex: int $for=10;
\or double $false=20;


Happy Programming

4G

4G is a collection of fourth generation cellular data technologies. It succeeds 3G and is also called "IMT-Advanced," or "International Mobile Telecommunications Advanced." 4G was made available as early as 2005 in South Korea under the name WiMAX and was rolled out in several European countries over the next few years. It became available in the United States in 2009, with Sprint being the first carrier to offer a 4G cellular network.
All 4G standards must conform to a set of specifications created by the International Telecommunications Union. For example, all 4G technologies are required to provide peak data transfer rates of at least 100 Mbps. While actual download and upload speeds may vary based on signal strength and wireless interference, 4G data transfer rates can actually surpass those ofcable modem and DSL connections.
Like 3G, there is no single 4G standard. Instead, different cellular providers use different technologies that conform to the 4G requirements. For example, WiMAX is a popular 4G technology used in Asia and Eastern Europe, while LTE (Long Term Evolution) is more popular in Scandinavia and the United states.

Tech Acronyms - Computer and Internet acronyms

AcronymMeaning
ACLAccess Control List
ADCAnalog-to-Digital Converter
ADFAutomatic Document Feeder
ADSLAsymmetric Digital Subscriber Line
AGPAccelerated Graphics Port
AIFFAudio Interchange File Format
AIXAdvanced Interactive Executive
ALUArithmetic Logic Unit
ANSIAmerican National Standards Institute
APIApplication Program Interface
ARPAddress Resolution Protocol
ASCIIAmerican Standard Code for Information Interchange
ASPActive Server Page or Application Service Provider
ATAAdvanced Technology Attachment
ATMAsynchronous Transfer Mode
BASICBeginner's All-purpose Symbolic Instruction Code
BccBlind Carbon Copy
BIOSBasic Input/Output System
BlobBinary Large Object
BMPBitmap
BSODBlue Screen of Death
CADComputer-Aided Design
CcCarbon Copy
CCDCharged Coupled Device
CDCompact Disc
CD-RCompact Disc Recordable
CD-ROMCompact Disc Read-Only Memory
CD-RWCompact Disc Re-Writable
CDFSCompact Disc File System
CDMACode Division Multiple Access
CGICommon Gateway Interface
CISCComplex Instruction Set Computing
CLOBCharacter Large Object
CMOSComplementary Metal Oxide Semiconductor
CMSContent Management System
CMYKCyan Magenta Yellow Black
CPACost Per Action
CPCCost Per Click
CPLCost Per Lead
CPMCost Per 1,000 Impressions
CPSClassroom Performance System
CPUCentral Processing Unit
CRMCustomer Relationship Management
CRTCathode Ray Tube
CSSCascading Style Sheet
CTPComposite Theoretical Performance
CTRClick-Through Rate
DACDigital-to-Analog Converter
DAWDigital Audio Workstation
DBMSDatabase Management System
DCIMDigital Camera IMages
DDLData Definition Language
DDRDouble Data Rate
DDR2Double Data Rate 2
DDR3Double Data Rate Type 3
DFSDistributed File System
DHCPDynamic Host Configuration Protocol
DIMMDual In-Line Memory Module
DLCDownloadable Content
DLLDynamic Link Library
DMADirect Memory Access
DNSDomain Name System
DOSDisk Operating System
DPIDots Per Inch
DRAMDynamic Random Access Memory
DRMDigital Rights Management
DSLDigital Subscriber Line
DSLAMDigital Subscriber Line Access Multiplexer
DTDDocument Type Definition
DVDigital Video
DVDDigital Versatile Disc
DVD+RDigital Versatile Disc Recordable
DVD+RWDigital Versatile Disk Rewritable
DVD-RDigital Versatile Disc Recordable
DVD-RAMDigital Versatile Disc Random Access Memory
DVD-RWDigital Versatile Disk Rewritable
DVIDigital Video Interface
DVRDigital Video Recorder
ECCError Correction Code
EDIElectronic Data Interchange
EIDEEnhanced Integrated Drive Electronics
EPSEncapsulated PostScript
EUPEnterprise Unified Process
EXIFExchangeable Image File Format
FAQFrequently Asked Questions
FDDIFiber Distributed Data Interface
FIFOFirst In, First Out
FiOSFiber Optic Service
FLOPSFloating Point Operations Per Second
FPUFloating Point Unit
FSBFrontside Bus
FTPFile Transfer Protocol
GbpsGigabits Per Second
GIFGraphics Interchange Format
GIGOGarbage In, Garbage Out
GISGeographic Information Systems
GPSGlobal Positioning System
GPUGraphics Processing Unit
GUIGraphical User Interface
GUIDGlobally Unique Identifier
HDDHard Disk Drive
HDMIHigh-Definition Multimedia Interface
HDTVHigh Definition Televsion
HDVHigh-Definition Video
HFSHierarchical File System
HSFHeat Sink and Fan
HTMLHyper-Text Markup Language
HTTPHyperText Transfer Protocol
HTTPSHyperText Transport Protocol Secure
I/OInput/Output
ICANNInternet Corporation For Assigned Names and Numbers
ICFInternet Connection Firewall
ICMPInternet Control Message Protocol
ICSInternet Connection Sharing
ICTInformation and Communication Technologies
IDEIntegrated Device Electronics or Integrated Development Environment
IEEEInstitute of Electrical and Electronics Engineers
IGPIntegrated Graphics Processor
IMInstant Message
IMAPInternet Message Access Protocol
InterNICInternet Network Information Center
IPInternet Protocol
IPXInternetwork Packet Exchange
IRCInternet Relay Chat
IRQInterrupt Request
ISAIndustry Standard Architecture
iSCSIInternet Small Computer Systems Interface
ISDNIntegrated Services Digital Network
ISOInternational Organization for Standardization
ISPInternet Service Provider
ITInformation Technology
IVRInteractive Voice Response
JFSJournaled File System
JPEGJoint Photographic Experts Group
JREJava Runtime Environment
JSFJavaServer Faces
JSONJavaScript Object Notation
JSPJava Server Page
KbpsKilobits Per Second
KDEK Desktop Environment
KVM SwitchKeyboard, Video, and Mouse Switch
LAMPLinux, Apache, MySQL, and PHP
LANLocal Area Network
LCDLiquid Crystal Display
LDAPLightweight Directory Access Protocol
LEDLight-Emitting Diode
LIFOLast In, First Out
LPILines Per Inch
LTELong Term Evolution
LUNLogical Unit Number
MAC AddressMedia Access Control Address
MAMPMac OS X, Apache, MySQL, and PHP
MANETMobile Ad Hoc Network
MbpsMegabits Per Second
MBRMaster Boot Record
MCAMicro Channel Architecture
MIDIMusical Instrument Digital Interface
MIPSMillion Instructions Per Second
MMSMultimedia Messaging Service
MP3MPEG-1 Audio Layer-3
MPEGMoving Picture Experts Group
MTUMaximum Transmission Unit
NATNetwork Address Translation
NetBIOSNetwork Basic Input/Output System
NICNetwork Interface Card
NNTPNetwork News Transfer Protocol
NOCNetwork Operations Center
NTFSNew Technology File System
NUINatural User Interface
NVRAMNon-Volatile Random Access Memory
OASISOrganization for the Advancement of Structured Information Standards
OCROptical Character Recognition
ODBCOpen Database Connectivity
OEMOriginal Equipment Manufacturer
OLAPOnline Analytical Processing
OLEObject Linking and Embedding
OOPObject-Oriented Programming
OSDOn Screen Display
OSPFOpen Shortest Path First
P2PPeer To Peer
PCPersonal Computer
PCBPrinted Circuit Board
PCIPeripheral Component Interconnect
PCI-XPeripheral Component Interconnect Extended
PCMCIAPersonal Computer Memory Card International Association
PDAPersonal Digital Assistant
PDFPortable Document Format
PHPHypertext Preprocessor
PIMPersonal Information Manager
PMUPower Management Unit
PNGPortable Network Graphic
POP3Post Office Protocol
POSTPower On Self Test
PPCPay Per Click
PPGAPlastic Pin Grid Array
PPIPixels Per Inch
PPLPay Per Lead
PPMPages Per Minute
PPPPoint to Point Protocol
PPPoEPoint-to-Point Protocol over Ethernet
PPTPPoint-to-Point Tunneling Protocol
PRAMParameter Random Access Memory
PROMProgrammable Read-Only Memory
PS/2Personal System/2
PUMPotentially Unwanted Modification
PUPPotentially Unwanted Program
QBEQuery By Example
RAIDRedundant Array of Independent Disks
RAMRandom Access Memory
RDFResource Description Framework
RDRAMRambus Dynamic Random Access Memory
RFIDRadio-Frequency Identification
RGBRed Green Blue
RISCReduced Instruction Set Computing
ROMRead-Only Memory
RPCRemote Procedure Call
RPMRevenue Per 1,000 Impressions
RSSRDF Site Summary
RTERuntime Environment
RTFRich Text Format
RUPRational Unified Process
SaaSSoftware as a Service
SANStorage Area Network
SATASerial Advanced Technology Attachment
SCSISmall Computer System Interface
SDSecure Digital
SDKSoftware Development Kit
SDRAMSynchronous Dynamic Random Access Memory
SDSLSymmetric Digital Subscriber Line
SEOSearch Engine Optimization
SERPSearch Engine Results Page
SIMMSingle In-Line Memory Module
SIPSession Initiation Protocol
SKUStock Keeping Unit
SLASoftware License or Service Level Agreement
SLIScalable Link Interface
SMARTSelf-Monitoring Analysis And Reporting Technology
SMBServer Message Block
SMMSocial Media Marketing
SMSShort Message Service
SMTPSimple Mail Transfer Protocol
SNMPSimple Network Management Protocol
SO-DIMMSmall Outline Dual In-Line Memory Module
SOAService Oriented Architecture
SOAPSimple Object Access Protocol
SQLStructured Query Language
SRAMStatic Random Access Memory
sRGBStandard Red Green Blue
SSDSolid State Drive
SSHSecure Shell
SSIDService Set Identifier
SSLSecure Sockets Layer
TCP/IPTransmission Control Protocol/Internet Protocol
TFTThin-Film Transistor
TIFFTagged Image File Format
TTLTime To Live
TWAINToolkit Without An Informative Name
UATUser Acceptance Testing
UDDIUniversal Description Discovery and Integration
UDPUser Datagram Protocol
UGCUser Generated Content
UMLUnified Modeling Language
UNCUniversal Naming Convention
UPnPUniversal Plug and Play
UPSUninterruptible Power Supply
URIUniform Resource Identifier
URLUniform Resource Locator
USBUniversal Serial Bus
UTFUnicode Transformation Format
VCIVirtual Channel Identifier
VDSLVery High Bit Rate Digital Subscriber Line
VDUVisual Display Unit
VFATVirtual File Allocation Table
VGAVideo Graphics Array
VLBVESA Local Bus
VLEVirtual Learning Environment
VoIPVoice Over Internet Protocol
VPIVirtual Path Identifier
VPNVirtual Private Network
VRAMVideo Random Access Memory
VRMLVirtual Reality Modeling Language
W3CWorld Wide Web Consortium
WAISWide Area Information Server
WAMPWindows, Apache, MySQL, and PHP
WANWide Area Network
WDDMWindows Display Driver Model
WEPWired Equivalent Privacy
Wi-FiWireless Fidelity
WINSWindows Internet Name Service
WPAWi-Fi Protected Access
WWWWorld Wide Web
XHTMLExtensible Hypertext Markup Language
XMLExtensible Markup Language
XSLTExtensible Style Sheet Language Transformation
Y2KYear 2000
ZIFZero Insertion Force