Wednesday, September 2, 2009

HTML mailto attribute

The mailto is a quick way to add the facility of receiving feedback from visitor on your web site. With the HTML mailto, you create a link which when clicked by the visitor launches (if it's not already running) their email program with a new email message window. The visitor could then formulate the email message and send it off to you.

Note: HTML Mailto assumes that the visitor has configured an email client (Outlook Express, Netscape Messenger, Thunderbird or any other) to send emails.

In its simplest form, the HTML mailto requires an email address. However, mailto can be made slightly more professional if we use it properly.


The Basic form of HTML mailto

mailto looks like:


Send me an
email




And this is displayed as



A more complex HTML mailto


We will now learn how to create a more complex HTML mailto by adding an email subject and the email body so that it looks a little more professional. And this will definitely save your visitors some typing too!



Send me an email






Careful inspection of the above code will highlight two points. Firstly, the email address is separated from the other information by a ? sign (question mark) and secondly, body and subject properties are themselves separated using an &.

[Those of you familiar with server-side scripting will find a similarity between this mailto tag and the GET method.]

Remember, the prefilled email Subject and email body values can be changed by the visitor! But this fancy mailto looks better than plain one, doesn't it?

In addition to the body and subject, we can also provide HTML mailto with CC (Carbon Copy) and BCC (Blind Carbon Copy). This, as you would have guessed, requires us to append these values to the HTML mailto attribute just like we had done for body and subject. [Refer code and image below]




Send me an email





Thursday, August 27, 2009

JDK API search in Google Toolbar

For those of you who use the Google Toolbar, the following links will add a Java API search button to your toolbar. I've found this to be a very handy way to locate the javadoc for the platform.

Add Java SE 6 API search box to Google Toolbar

Add OpenJDK API search box to Google Toolbar

Tuesday, July 14, 2009

All About CSS

URL : http://www.cssportal.com/


Here at CSSPortal, we have gathered as much information as possible to try and help you learn CSS and improve your web design skills.



At this site, you'll find a range of quality resources all geared towards CSS, if you're looking for a new design for your website, then please check out our range of CSS templates or if you would like to design your own site, you may wish to check out some software to help, go to CSS software for some great programs. Also at CSSPortal, you'll find all the CSS properties, CSS books and a nice collection of CSS examples.

CSS Menu Generator has been updated to make it more user friendly.

- CSS properties list has been updated to include CSS 3 Properties.
- New CSS tool has just been released, Format CSS Code.
- Check out our new page about CSS3 Examples.

URL : http://www.cssportal.com/

Different Style in HTML Text Field

CSS Text Box Element



CSS Code



/* Text Box with Different Border: */
.tb-border {
border: 1px solid #0000FF;
}

/* Text Box with Background Color: */
.tb-background {
background-color : #99FFCC;
border: 1px solid #008000;
}

/* Text Box with Background Image: */
.tb-bg-image {
background-image: url(bg.png);
border: 1px solid #6297BC;
}

/* Text Box with Focus: */
.tb-focus {
border: 1px solid #888377;
}
.tb-focus:focus {
background-color: #F4EEDD;
}

/* Text Box with Side Image: */
.tb-bg-side {
background-image: url(Portal.gif);
background-repeat:no-repeat;
background-position:left;
border: 1px solid #6297BC;
padding-left:16px;
}

/* Text Box with Rounded Corners: */
.tb-rounded {
border:0;
background: transparent url(rounded.gif) no-repeat top left;
height: 22px;
width: 230px;
padding-top:2px;
}

/* Text Box with Gradient: */
.tb-gradient {
border:0;
background: transparent url(gradient.gif) no-repeat top left;
height: 22px;
width: 230px;
padding-top:2px;
}




Source: http://www.cssportal.com/form-elements/text-box.htm
Demo: View Demo

jCarousel-jQuery plugin

jCarousel description


jCarousel is a jQuery plugin for controlling a list of items in horizontal or vertical order.
jCarousel is a jQuery plugin for controlling a list of items in horizontal or vertical order.
The items, which can be static HTML content or loaded with (or without) AJAX, can be scrolled back and forth (with or without animation).

To use the jCarousel component, include the jQuery library, the jCarousel source file, the jCarousel core stylesheet file and a jCarousel skin stylesheet file inside the head tag of your HTML document.
--------------------------------------------------
--------------------
Home Page: http://sorgalla.com/jcarousel/
Demo: View Demo
Download :
Download jCarousel
Documentation: http://sorgalla.com/projects/jcarousel/
Examples : http://sorgalla.com/jcarousel/
----------------------------------------------------------------------

Monday, July 6, 2009

How to turn on log4j debug

use this jvm flag : -Dlog4j.debug

How to disable copy paste and autocomplete for an HTML textbox


INPUT size=12 name=”FundsTransferTo” maxlength=12 onCopy=”return false” onDrag=”return false” onDrop=”return false” onPaste=”return false” autocomplete=off;

Wednesday, June 10, 2009

Batch File To Create Restore Point








runas /user:local\administrator
@
echo off
title Test Utility
:prompt
color 4f
cls
echo Pick a Category
echo.
echo Type 1 to System Utilities
echo Type 2 to ""
echo Type 3 to ""

set /p answer=
if ‘%answer%’ == ‘1’ system

:system
cls
Echo Type 1 to System Restore
Echo Type 2 to ""
Echo Type 15 to Main Menu

set /p answer=
if '%answer%' == '1' goto system restore

:system restore
cls
IF EXIST %systemroot%\system32\restore\rstrui.exe= %systemroot%\system32\restore\rstrui.exe else
IF EXIST C:\Windows\System32\rstrui.exe = C:\Windows\System32\rstrui.exe
echo.
echo Pres Any Key to goto Menu
pause >nul
goto prompt

Create .VBS file To Create Restore Point

Step-1 Open Notepad
Step-2 Copy below code to Noteoad

set SRP = getobject("winmgmts:\\.\root\default:Systemrestore")
CSRP = SRP.createrestorepoint ("Restore Point Created By-Chintan Patel", 0, 100)

Step3 Save as RestorePoint.vbs
Step-4 Double click on RestorePoint.vbs to Take Restore Point


Note:
If you want to Take Restore Point when system start,
then drag that file in to STARTUP

How to Start the System Restore Tool from a Command Prompt



To start the System Restore tool when you cannot start your Windows Me-based computer normally or in Safe mode, you can temporarily change the Windows shell from Explorer.exe to Progman.exe:
  1. Start your computer by using the Windows Me Startup disk.
  2. At the Startup menu, choose Minimum Boot.
  3. At the command prompt, type edit c:\windows\system.ini, and then press ENTER.
  4. Edit the shell= line so that it looks like this:
    shell=progman.exe
  5. Press ALT+F, and then press S to save the changes to the System.ini file.
  6. Press ALT+F, and then press X.
  7. Remove your Windows Me Startup disk, and then restart your computer. When your computer restarts, Program Manager should start. If Program Manager does not start, repeat steps 1 through 7, being careful to follow these steps exactly, and then continue to the next step.
  8. On the File menu, click Run, type msconfig in the Command Line box, and then press ENTER.
  9. Click Launch System Restore to begin restoring your computer to a previous, functional state.


Notes

  • After you configure your computer to start Program Manager (Progman.exe), you can also start the System Restore tool by typing c:\windows\system\restore\rstrui.exe at a command prompt, and then pressing ENTER.
  • If you still cannot use System Restore, repeat steps 1 through 6. In step 4, change the shell= line so that it reads:
    shell=explorer.exe
    This sets the Windows shell back to Explorer.exe so that you can continue troubleshooting.

Tuesday, June 9, 2009

Have You Visit eHow ?

Have You Visit eHow ?


Print (Silent Print) From Java Applet

import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.*;

import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.swing.*;

public class CopyOfPrinterApplet extends JApplet {

private PrintRequestAttributeSet aset;
DocFlavor DocFlavor;
public Doc doc;
DocPrintJob printerJob;
JTextPane pane;


/**
* DOCUMENT ME!
*/
public void init() {
getContentPane().setLayout(new BorderLayout());

pane = new JTextPane();
pane.setSize(150, 100);
pane.setContentType("text/html");
pane.setText(

"<center><b><big>Applet Test</big></b>

"

+ "</center>");

getContentPane().add(pane, "Center");

JPanel buttons = new JPanel();
buttons.setBackground(Color.white);

JButton print = new JButton("Print");

buttons.add(print);

getContentPane().add(buttons, "South");

print.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
print();
}
});
}

/**
* DOCUMENT ME!
*/
void prep() {

URL url = null;
aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
aset.add(new Copies(1));

try {
url =
new URL("http://www.emanuelblagonic.com/wp-content/uploads/2007/06/google-homepage.jpg");
} catch (MalformedURLException e) {
e.printStackTrace();
}
PrintService pservices =
PrintServiceLookup.lookupDefaultPrintService();
System.out.println(pservices.getName());

DocFlavor flavor = javax.print.DocFlavor.INPUT_STREAM.JPEG;
PrintRequestAttributeSet attr_set = new HashPrintRequestAttributeSet();
attr_set.add(new Copies(1));
PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, attr_set);

doc = new SimpleDoc(url, javax.print.DocFlavor.URL.PDF, null);

try {
System.out.println("DOC : \n " + doc.getPrintData());
} catch (IOException e) {
e.printStackTrace();
}
/* Create a Print Job */
printerJob = pservices.createPrintJob();
}

/**
* DOCUMENT ME!
*/
void print() {
prep();
System.out.println("Printer Name : " +
printerJob.getPrintService());
try {
printerJob.print(doc, aset);

} catch (PrintException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Done Printing.");
}

}

Wednesday, May 27, 2009

What does rt.jar stand for in Java/JDK/JRE?

The most likely answer is, rt stands for RunTime. Some tend to think it stands for RooT, since this jar contains all java build-in classes. But I have yet to find any official Sun documents regarding this acronym.
Whether it stands for RunTime, RooT, or anything else is not important. The question I have is, why would the java creator chose to use such a undescriptive name. Maybe it can make your classpath shorter? But we rarely put rt.jar in system classpath.
Here are 2 reasons I don't like the name rt.jar:
* While experienced developers take it for granted, java beginners don't know what it is other than it's a jar. So it's one more questions in beginners' mind.
* The shorter the name, the easier it is to cause naming conflicts, at least visually. While rt.jar will always reside under $JAVA_HOME/jre/lib, it is possible your applications may have another jar also named rt.jar.
I know rt.jar will be with us as long as java is, but just for the sake of discussion, how would you name it differently? Maybe java.jar, or java-core.jar?
PS: What does jar stand for? Jar stands for Java Archive. A jar file usually has file name extension .jar. It contains mainly java class files but any types of files can be included, e.g., XML files, HTML files, properties files, gif/jpg image files, text files, PDF files, and binary files, and so on.
PS: What is the difference between a jar file and a zip file? Basically, a jar file is the same as a zip file, except that the jar file contains a META-INF directory to store metadata or attributes. The most well-known file is META-INF/MANIFEST.MF. You can customize the content of a MANIFEST.MF when creating a jar file, and if you don't, a default one is generated and included. For example:
Manifest-Version: 1.0
Created-By: 1.5.0_06 (Sun Microsystems Inc.)
It's perfectly fine to have other configuration files and directories under META-INF.

Java Jar File Naming Conventions and Examples.

util.jar is the worst jar file name I can think of. All I know is it contains some utility/helper classes. But it is unclear if they belong to an application server, or a framework, or any application sub-systems. You will need to ask someone or some docs to know what it is. It's part of the DataDirect JDBC Driver distribution.
On the other hand, good jar file names are always self-explanatory, for example: struts.jar, jboss-system.jar, commons-pool-1.1.jar
Some thoughts on jar file naming conventions:
1. Always use extension ".jar", not ".zip"
Theoretically, jar files can have any extension or no extension at all. If you specify it in the system classpath, it should be loadable. The problem is with automatic library detection and loading by containers and frameworks. It's expensive to scan all files so some sort of extension restriction is needed. For this reason, J2EE/JavaEE platform spec requires all library jar files use ".jar" extension, such as WEB-INF/lib/mybeans.jar.
2. Use hyphen (-) instead of underscore (_) as word separator
First, it's easier to type - than _; secondly, when the file name is underlined (e.g., in a hyperlink), the _ is invisible. Hyphen has been shunned in file names partly because it is an illegal character in java identifier. But this concern is unwarranted.
3. Append version number if distributed standalone
because they can be dropped into any applications, which may need specific versions. We don't want users to have to compare file size or extract some META-INF files to know its version. Some examples: hibernate3.jar, commons-logging-1.0.3.jar, and
log4j-1.2.8.jar.
4. Don't append version number if bundled inside other larger deliverables
because the enclosing deliverables, such as an application server (e.g., JBoss 4.0.4, jakarta-tomcat-5), a tool(e.g., apache-ant-1.6.5), aleady have the version numbers, thus no version number for jboss.jar, catalina.jar, and ant.jar.

The Worst Java Job Interview Questions.

Why are you looking for a job?
Strictly speaking, this is not a java question, but it shows up in almost every job interview I've been to. The interviewer is testing the candidate's motivation for a job change. Invariably, the answer will be something like, advancing career and professional development. Of course, the candidate won't tell you he/she is looking for a 15% salary increase to cover the gas price increase, or he doesn't get along with his co-workers, or he didn't get the promotion or bonus, or he was rated Under-Perform in last year's performance review.
Which OS do you use in your development work, Linux, Windows, or Solaris?
Java is cross-platform, and I couldn't care less about OS while I'm writing java code. Unless the job is specifically about porting applications to other OS and deploying/distributing applications, I don't see how this is relevant. J2EE, JavaEE and Web applications are all made up of components that are managed by the application server, and thus shielded from the underlying OS.
Are you familiar with Oracle Database, or DB2?
Java persistence can now be easily achieved with ORM frameworks such as Hibernate, TopLink. The latest release of EJB 3 and Java Persistence API has standardize the way persistence is done in Java, J2EE, and JavaEE. The goal of these industry efforts is to let Java developers forget database stuff, which should be left to DBA. Even if Java developers in this project need to deal with database directly, I suppose they need to know about database design concepts and SQL, not some Oracle or DB2 stored procedures.