Saturday, January 7, 2012

eclipse crash while starting tomcat server


While Just starting with eclipse stuck with one of the issue that is server --> Tomcat server is not starting up.

I found the solution here: http://forums.opensuse.org/applications/391114-tomcat6-eclipse-not-working.html
1. In Eclipse, Open the "Server" tab.
2. Double click on the "Tomcat6" entry to see the configuration.
3. Then click on the "Open launch configuration" link in the "General information" block.
4. In the dialog, select the "Classpath" tab.
5. Click the "Add external jar" button.
6. Select the file "/usr/share/tomcat6/bin/tomcat-juli.jar"
7. Close the dialog.
8. Start tomcat 6 from Eclipse.
Hopefully posting it here will help some poor soul.

Saturday, May 1, 2010

VIM commands

Hello,

I wont to right some thing about VIM, VI Editor

There are so many editors but vi editor is the most used editor in linux.

Below is the link for all simple copy, paste open kind of commands for vi editors

http://www.tuxfiles.org/linuxhelp/vimcheat.html

That's OK,

But some times question arise,

If I want to copy some line something from one file and paste it into another file then?

Cause if I close one file and open another it will flush the buffer generated for first file.

There is one more command in editor to do this.

:1,50w >> ../../fileName.txt

This will copy lines 1 to 50 from current file and paste it to the file located in given place.

for copying single line and paste (append) it to another file use

:25w >> ../../fileName.txt

MySqldump

Hi friends,

If you find Mysqldump on google you will find lots of website to create dump file, backup file from existing one or more databases of mysql and restore it.

Best link is,

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html


I want to just write a little bit thing that I searched lot.

That when we generate dump - sql - backup file from mysql, uses command

shell>> mysqldump -u uname -p dbname > dbfile.sql

That will back complete database to dbfile.sql

When on reverse, if I tried to restore that database from dbfile.sql

on Windows it works using same mysqldump

c://MySql//bin> mysqldump dbname < dbfile.sql

Just difference of < and >

while the same thing in linux not works
It will purform and shows output as below

-- MySQL dump 10.11
--
-- Host: localhost Database: royaleducation
-- ------------------------------------------------------
-- Server version 5.0.51a-3ubuntu5.5

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2010-05-01 13:02:48


It says Dump completed but when we goto that perticular database and show tables
It will give 0 tables there in database.
for linux we have to use mysql command

shell>> mysql -u root -p dbname < dffile.sql

That will works well.

but for that required to create database first in mysql.

Monday, September 8, 2008

JSP page back and forward on Same Page

Hi, Friends

Today I have been faced problem for forwarding from JSP page to servlet and from servlet to the Page (Jsp) from which it is called.

I think you are not understanding...

Let's understand by one example...

Let say, I have three consecutive lists one is for country, second is for state and 3rd one is for city..

And I want to get one by one information. One depends on another one. If I select Country = "india" I will get all the state inside India. And the same way Once I select state I will get city information regarding it.

Now that is very easy using AJAX but consider I don't know AJAX (And right I don't know AJAX. Will learn shortly). Now we have 2 options first one is to on change event of first list data I will send request to server. Server get related information from database. send back to the same page. (dispacher(request, response). All Content I will get as ArrayList at jsp. I will loop this arraylist and get back all related content and put it in list. And the same way change on second list data I will send request to database and get back information.

That is main logic behind it...

Another way is Java Script..(I have not even try for that)

In this one there will be structure of java script such that each elements are connected each other.That is fastes rather then previous one. No server side callings need every time. (that's why)

will right code for that in few time..

Thanks to read my blog.

Sunday, September 7, 2008

Sending Mail Through GMail Account Using Java Code

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class Main {
String d_email = "your_email_id@gmail.com", 
                  d_password = "your_password",
                  d_host = "smtp.gmail.com", 
                  d_port = "465", 
                  m_to = "email_to@any.any",
                  m_subject = "Testing", 
                  m_text = 
                  "<h1>
                     Hey, this is the testing email.
                   </h1> 
                   <a href="http://softwaresafar.blogspot.com/"> 
                     Check this Link for development solution 
                   </a>";

public Main() {
  Properties props = new Properties();
  props.put("mail.smtp.user", d_email);
  props.put("mail.smtp.host", d_host);
  props.put("mail.smtp.port", d_port);
  props.put("mail.smtp.starttls.enable", "true");
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.debug", "true");
  props.put("mail.smtp.socketFactory.port", d_port);
  props.put("mail.smtp.socketFactory.class",
          "javax.net.ssl.SSLSocketFactory");
  props.put("mail.smtp.socketFactory.fallback", "false");

  SecurityManager security = System.getSecurityManager();

  try {
      Authenticator auth = new SMTPAuthenticator();
      Session session = Session.getInstance(props, auth);
      // session.setDebug(true);

      MimeMessage msg = new MimeMessage(session);
      //msg.setText(m_text);
      msg.setContent(m_text, "text/html");

      msg.setSubject(m_subject);
      msg.setFrom(new InternetAddress(d_email));
      msg.addRecipient(Message.RecipientType.TO,
              new InternetAddress(m_to));
      Transport.send(msg);
      System.out.println("Message send successfully");
  } catch (Exception mex) {
      mex.printStackTrace();
  }
}

public static void main(String[] args) {
  Main blah = new Main();
}

private class SMTPAuthenticator extends javax.mail.Authenticator {
  public PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(d_email, d_password);
  }
}
}



  • You can also send multiple message by chenging few
    things from this code.

  • You need to download some jar files also for this one.

  • mail.jar

  • activation.jar

  • search for that and download it.



download your code from here

The day of beginning

Hi, Friends,

The word written here friends is not just a simple word. Strength of this word is very high. I want to make new friends who are in the field of software. I am software engineer from India and currently working as software developer. So it's final I am gone through so many problems. I decided to make one blog that will help all my developer friends to solve problems that I face. As well as I can put up my problems also that they can come to know and answer me. Any one can mail me also regarding their development problem I will try my best to give them answer.