Send SMS Through JAVA/JSP/ SERVLETS

Send SMS Through JAVA/JSP/ SERVLETS

Hi, Friends with this post i will show to how to send an sms through JAVA/JSP/SERVLETS

For sending sms I am using mvayoo.

First what is mVaayoo, It  is a cost effective End-to-End Enterprise Mobile Messaging Service with high service level availability, that is unmatched in the industry. mVaayoo provides both 1-Way & 2-Way SMS communication including SMS Push, short code and long code services, SMS gateway with APIs, SMS Excel plugin, SMS contest, voting & polling and Voice SMS services.

URL : http://www.mvayoo.com


You first register in this website and continue your tutorial ...
 
------------------------------------------------------------------------------------------------------------
Note  : We can send only 20 sms with the free account... If you want more choose the premium plan or register with another account.

------------------------------------------------------------------------------------------------------------

coming to the program...;


import java.io.*;
import java.security.*;

import java.net.*;

public class SMS  //Save the file with the name "SMS.java"
{
    public static void main(String[] args)
    {
        String phnum= "9292929292";   // Example Phone Number
        String message = "Hai, How are you ..."; //Example Message
        try{ 



//http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST SMS&receipientno=RECEIPIENTNO&dcs=0&msgtxt=This is Test message&state=4              

   URL myurl = new URL("http://api.mvaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST%20SMS&receipientno="+phnum+"&dcs=0&msgtxt="+message+"");
 
  BufferedReader in = new BufferedReader(new InputStreamReader(myurl.openStream())); 
  String inputLine;

 while ((inputLine = in.readLine())!= null)
          System.out.println(inputLine);


in.close();
}
catch(Exception e){
            System.out.println("error"+e);


}
 

}

}

OUTPUT :

Hai, How are you ...

Status=0,ins37_14066345089954

Observe the output, in output "Hai, How are you ..." is our message and the second line is for status indication if your message is send successful it shows the output like "Status=0", Other wise it will not send ..


------------------------------------------------------------------------------------------------------------
NOTE : INTERNET Connection must required for sending an sms ...


------------------------------------------------------------------------------------------------------------
Retrieval Image From DataBase and Display on WebPage by Using Servlets.

Retrieval Image From DataBase and Display on WebPage by Using Servlets.

Hi Frnds, This Session I will Explain you to "How Retrive Image from DataBase Using Servlets and Display it on WebPage"

The below code is useful for Retrive Image from DataBase Using Servlets and Display it on WebPage.

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.annotation.WebServlet;

@WebServlet("/ImageDis")

public class ImageDis extends HttpServlet
{
public void service(HttpServletRequest request,HttpServletResponse response)  throws IOException,ServletException
{
 response.setContentType("image/jpeg");

Blob image = null;
Connection con = null;
byte[ ] imgData = null ;
Statement stmt = null;
ResultSet rs = null;

try {

Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DbName","UserName","Password");
stmt = con.createStatement();
// Retrieve Image from DataBase using MySQL Query Based on Condition...;
rs = stmt.executeQuery("select imge from empde where id='12'");

if (rs.next()) {
                               //Getting Image From DataBase...;
image = rs.getBlob(1);
imgData = image.getBytes(1,(int)image.length());

} else {
System.out.println("Display Blob Example");
System.out.println("image not found for given id>");

}
// display the image...;

ServletOutputStream out1 = response.getOutputStream();
BufferedOutputStream bout = new BufferedOutputStream(out1);
   
bout.write(imgData);

} catch (Exception e) {
System.out.println("Unable To Display image");
System.out.println("Image Display Error=" + e.getMessage());
} finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

Check the OutPut If you have any Doubts Leave your Comments Below...;

Have a Gr8 Day Frnds...;)
75 inspirational quotes that will change your life

75 inspirational quotes that will change your life

1 of 75

Oprah Winfrey

Quote: "You become what you believe."

2 of 75

Margaret Thatcher

Quote: "You may have to fight a battle more than once to win it.

3 of 75

Steve Jobs

Quote: "The only way to do great work is to love what you do."

4 of 75

Audrey Hepburn

Quote: "Nothing is impossible, the word itself says, 'I'm possible!'"


5 of 75

Dalai Lama

Quote: "Happiness is not something readymade. It comes from your own actions."

6 of 75

Amelia Earhart

Quote: "The most difficult thing is the decision to act, the rest is merely tenacity."

7 of 75

Dolly Parton

Quote: "If you see someone without a smile give them yours."

8 of 75

Jane Fonda

Quote: "It's never to late- never to late to change your life,never to late to be happy."

9 of 75

Cate Blanchett

Quote: "If you know you are going to fail, then fail gloriously."

10 of 75

Drew Barrymore

Quote: "Life is very interesting... in the end, some of your greatest pains, become your greatest strengths."

11 of 75

Bruce Lee

Quote: "If you love life, don't waste time, for time is what life is made up of."

12 of 75

John Lennon

Quote: "Life is what happens to you while you're busy making other plans."

13 of 75

Matt Damon

Quote: "Eventually stardom is going to go away from me. It goes away from everybody and all you have in the end is to be able to look back and like the choices you made."

14 of 75

Katie Holmes

Quote: "We all keep dreaming, and luckily, dreams really do come true."

15 of 75

Sylvester Stallone

Quote: "I believe there's an inner power that makes winners or losers. And the winners are the ones who really listen to the truth of their hearts."

16 of 75

Jack Nicholson

Quote: "The minute that you're not learning I believe you're dead."

17 of 75

Jennifer Aniston

Quote: "There are no regrets in life. Just lessons."

18 of 75

Barack Obama

Quote: "Focusing your life solely on making a buck shows a certain poverty of ambition. It asks too little of yourself. Because it's only when you hitch your wagon to something larger than yourself that you realize your true potential."

19 of 75

Elvis Presley

Quote: "The image is one thing and the human being is another. It's very hard to live up to an image, put it that way."

20 of 75

Muhammad Ali

Quote: "I hated every minute of training, but I said, 'Don't quit. Suffer now and live the rest of your life as a champion.'!"

21 of 75

Warren Buffett

Quote: "Someone is sitting in the shade today because someone planted a tree a long time ago."

22 of 75

Michael Jackson

Quote: "Let us dream of tomorrow where we can truly love from the soul, and know love as the ultimate truth at the heart of all creation."

23 of 75

Ellen DeGeneres

Quote: "Find out who you are and be that person. That's what your soul was put on this Earth to be. Find that truth, live that truth and everything else will come."

24 of 75

Michael Jordan

Quote: "If you accept the expectations of others, especially negative ones, then you never will change the outcome."

25 of 75

Carol Burnett

Quote: "When you have a dream, you've got to grab it and never let go."

26 of 75

Morgan Freeman

Quote: "Learning how to be still, to really be still and let life happen - that stillness becomes a radiance."

27 of 75

Woody Allen

Quote: "Eighty percent of success is showing up."

28 of 75

Maya Angelou

Quote: "People will forget what you said. People will forget what you did. But people will never forget how you made them feel."

29 of 75

Lance Armstrong

Quote: "Pain is temporary. It may last a minute, or an hour, or a day, or a year, but eventually it will subside and something else will take its place. If I quit, however, it lasts forever."

30 of 75

Nelson Mandela

Quote: "It always seems impossible until it is done."

31 of 75

Jimmy Johnson

Quote: "The difference between ordinary and extraordinary is that little extra."

32 of 75

Alice Walker

Quote: "The most common way people give up their power is by thinking they don't have any."

33 of 75

Vince Lombardi

Quote: "Winning isn't everything, but wanting to win is."

34 of 75

Sheryl Sandberg

Quote: "If you're offered a seat on a rocket ship, don't ask what seat! Just get on."

35 of 75

Jesse Owens

Quote: "The battles that count aren't the ones for gold medals. The struggles within yourself-the invisible battles inside all of us-that's where it's at."

36 of 75

Gloria Steinem

Quote: "Dreaming, after all, is a form of planning."

37 of 75

Mae Jemison

Quote: "It's your place in the world; it's your life. Go on and do all you can with it, and make it the life you want to live."

38 of 75

Gary Player

Quote: "The harder I work, the luckier I get."

39 of 75

Billie Jean King

Quote: "Champions keep playing until they get it right."

40 of 75

Arnold Palmer

Quote: "Always make a total effort, even when the odds are against you."

41 of 75

Winston Churchill

Quote: "Success is walking from failure to failure with no loss of enthusiasm."

42 of 75

Albert Einstein

Quote: "Try not to become a person of success, but rather try to become a person of value."

43 of 75

Walt Disney

Quote: "All our dreams can come true if we have the courage to pursue them."

44 of 75

John Wooden

Quote: "Things work out best for those who make the best of how things work out."

45 of 75

Bill Clinton

Quote: "Character is a journey, not a destination."

46 of 75

Emma Stone

Quote: "You're only human. You live once and life is wonderful, so eat the damned red velvet cupcake."

47 of 75

Mahatma Gandhi

Quote: "You must be the change that you wish to see in the world."

48 of 75

John F. Kennedy

Quote: "Ask not what your country can do for you — ask what you can do for your country."

49 of 75

Sir Alex Ferguson

Quote: "Only true champions come out and show their worth after defeat- and I expect us to do that."

50 of 75

Bill Cosby

Quote: "I don't know the key to success, but the key to failure is trying to please everybody."

51 of 75

Ronald Reagan

Quote: "Nations do not mistrust each other because they are armed; they are armed because they mistrust each other."

52 of 75

Malala Yousafzai

Quote: "One child, one teacher, one book, one pen can change the world."

53 of 75

Kevin Costner

Quote: "When a defining moment comes along, you define the moment, or the moment defines you."

54 of 75

Malcolm Forbes

Quote: "The best vision is insight."

55 of 75

Ken Kesey

Quote: "You don't lead by pointing and telling people some place to go. You lead by going to that place and making a case."

56 of 75

Helen Keller

Quote: "The most pathetic person in the world is someone who has sight, but has no vision."

57 of 75

Mark Zuckerberg

Quote: "The question I ask myself like almost every day is, 'Am I doing the most important thing I could be doing?'... Unless I feel like I'm working on the most important problem that I can help with, then I'm not going to feel good about how I'm spending my time. And that's what this company is."

58 of 75

Tim Cook

Quote: "Life is fragile. We're not guaranteed a tomorrow so give it everything you've got."

59 of 75

Donald Trump

Quote: "Without passion, you don't have any energy, and without energy, you simply have nothing."

60 of 75

Michael Dell

Quote: "You don't need to be a genius or a visionary, or even a college graduate for that matter, to be successful. You just need framework and a dream."

61 of 75

Jeff Bezos

Quote: "In business, what's dangerous is not to evolve."

62 of 75

Larry Page

Quote: "If you're changing the world, you're working on important things. You're excited to get up in the morning."

63 of 75

Venus Williams

Quote: "Some people say I have attitude - maybe I do...but I think you have to. You have to believe in yourself when no one else does - that makes you a winner right there."

64 of 75

Angelina Jolie

Quote: "Without pain, there would be no suffering, without suffering we would never learn from our mistakes. To make it right, pain and suffering is the key to all windows, without it, there is no way of life."

65 of 75

Sachin Tendulkar

Quote: "It's about not accepting every challenge thrown at you. Sometimes you hold back and when it's needed you go for it."

66 of 75

Al Gore

Quote: "As human beings, we are vulnerable to confusing the unprecedented with the improbable. In our everyday experience, if something has never happened before, we are generally safe in assuming it is not going to happen in the future, but the exceptions can kill you and climate change is one of those exceptions."

67 of 75

Al Pacino

Quote: "Shakespeare's plays are more violent than 'Scarface.' "

68 of 75

Meryl Streep

Quote: "The great gift of human beings is that we have the power of empathy."

69 of 75

Ayrton Senna

Quote: "Winning is the most important. Everything is consequence of that."

70 of 75

Stevie Wonder

Quote: "If you don't ask, you don't get."

71 of 75

Martin Luther King Jr.

Quote: "In the End, we will remember not the words of our enemies, but the silence of our friends."

72 of 75

Robert De Niro

Quote: "If it's the right chair, it doesn't take too long to get comfortable in it."

73 of 75

Marilyn Monroe

Quote: "Fame doesn't fulfill you. It warms you a bit, but that warmth is temporary."
74 of 75

George Clooney

Quote: "You never really learn much from hearing yourself talk."
75 of 75

Diego Maradona

Quote: "When you win, you don't get carried away. But if you go step by step, with confidence, you can go far."

Source: www.msn.com

Displaying Text directly beside an image


Hi, Today i wanna show you how to Displaying Text With An Image Within HTML Code...;

If you're trying to place text directly beside an image within your web page HTML code, you may have discovered it's not as easy as it appears. When you place your image HTML code and text within your HTML code, instead of the text and image displaying side by side like a newspaper, it will display like this:


To enable your image and text to display properly together, you will need to add an ALIGN attribute to your image HTML code.

Following is an example image displaying on the left with the text wrapping around the image to the right.

To align your image to left and your text to the right, add ALIGN="left" to your image HTML code like this:

<img border="0" align="left" src="image.jpg"> Hai Frnds,How are You


Following is an example image displaying on the right with the text wrapping around the image to the left.

To align your image to right and your text to the left, add ALIGN="right" to your image HTML code like this:

<img border="0" align="Right" src="image.jpg"> Hai Frnds,How are you



Wrapping your text around your image will enable you to give your content a much more professional look.

Source : http://www.web-source.net/

Try It...,

Have a nice-day...;
JavaScript to Start and Stop the Time

JavaScript to Start and Stop the Time

Hi Frnds, I waana Show you how to Start and Stop the Time Using JavaScript...;

The Below Code is used to Start and Stop the Time Using JavaScript

<!DOCTYPE html>
<html>
<body>

<p>A script on this page Starts and Stops clock:</p>

<p id="demo"></p>

<div>
<form><input type = "submit" value = "Start Time" style = "float:left"></form>

<input type = "submit" value = "Stop Time" style = "margin-left:10px" onclick="myStopFunction()" ></div>

<script>
var myVar = setInterval(function(){ myTimer() }, 1000);

function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}

function myStopFunction() {
clearInterval(myVar);
}
</script>

</body>
</html>

Observe carefully this code

<p id = “demo”></p>
var myVar = setInterval(function(){ myTimer() }, 1000);

function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}

This code is used to display the Current System time, when page is loaded.

<input type = "submit" value = "Stop Time" style = "margin-left:10px" onclick="myStopFunction()" >

function myStopFunction() {
clearInterval(myVar);

When we click the “Stop Time” Button, the myStopFunction() is called. It Stops the Time.

<form><input type = "submit" value = "Start Time" style = "float:left"></form>

When we click the “Start Time” Button, the Page will refresh so the time will start again.

Try it...,


Have Nice Day...;