18 May, 2012

HTML/JAVASCRIPT: Creating a window in Javascript

Some times its an useful job to create a window with a new requirement. But , when we are in development room/area , we always remember any search engine to fine the solutions for any type of problem. Even I , also  following some of the search engine. 

But, it is a fact that I am always try to avoid this type of habits. Be , traceable  for finding any solution. This article is one of the mail memory & also my teaching my myself , that don't guess any coding is normal and easy , so don't remember.


So, below the topic:- code line put inside script tag


window.open('','','left=0,top=0,width=1000,height=780,toolbar=0,scrollbars=0,status=0');orwondow.open();

All parameters are not mandatory  to put with values. If you don't need any scrollbar,toolbar,status bar then you can put 0 as the value here, either put 1. 

17 May, 2012

How to set print area in JSP/HTML page for printer

This is one the interesting topic related to print the specific data from a jsp/html page. Directly to printer, without other browser data. I have done a quite obvious way in javascript for set the print area for printing. I faced this problem in my development team with me, for set a specific area for print.

Caution:-  Use of JavaScript may not be  always acceptable, due to client. If user/client disable the script setting in browser these may not work properly. But, every browsers are support script by default.  

As we know, window. Print() is used for print in JavaScript. There are so many ways to do a printing task in jsp/html page. Out of all I have mentioned 2 process below with advantage & disadvantage.  Put the below function in script area of your page:-

Procedure-1
function setDivPrint(val){
var printdata=document.getElementById('printarea').innerHTML;
var srcOriginalContent=document.body.innerHTML;
document.body.innerHTML=printdata;
window.print();
document.body.innerHTML=srcOrigionalContent;
}
Here ‘printarea ‘ is the id of printable div. It has some limitation, with getting the cancel button click event and some more. I am not mentioning all here. But in procedure-2 is so eminent than procedure-1.

Procedure-2

function setDivPrint(val){
var printdata=document.getElementById('printarea').innerHTML;
var printwindow=window.open('','','left=0,top=0,width=1000,height=780,toolbar=0,scrollbars=0,status=0');
printwindow.document.write(printdata);
printwindow.document.close();
printwindow.focus();
printwindow.print();
printwindow.close();
}

Here ‘printarea ‘ is the id of printable div. .This method is recommended to use. In this method no need to get the cancel or print button event. Suppose the user click on cancel, then the main original page should come, but it may not coming with the Procedure-1 . So, No need to face this problem in Procedure-2.

03 May, 2012

Manoj.Blog: MYSQL: Daily auto backup of database for windows o...

Manoj.Blog: MYSQL: Daily auto backup of database for windows o...: Quite simple , because you have read the older pos t for creating backup  (dump) . But, here the process of automatic backup the mysql data...

MYSQL: Daily auto backup of database for windows or Scheduled backup

Quite simple , because you have read the older post for creating backup  (dump) . But, here the process of automatic backup the mysql database in a particular time in your local system. This may not run your remote system.

Steps for create a schedule for back :-

 Step 1- Create a batch file with the command mysqldump and necessary options that mentioned in the old post .

Step 2- Goto Start => All program => Accessories => System Tool => Scheduled Task

Step 3- Then create a new schedule with given batch file and scheduled date & time.




Now ,  wait for the given scheduled  time and see the backup file is created in the destination directory .






Manoj.Blog: MYSQL:How to create MySql Dumps using batch file ...

Manoj.Blog: MYSQL:How to create MySql Dumps using batch file ...: Manoj.Blog: MYSQL:How to create MySql Dumps using batch file ... : Too much ,, really in MYSQL finding complete solution like oracle & sql ...

02 May, 2012

MYSQL:How to create MySql Dumps using batch file ...

Manoj.Blog: MYSQL:How to create MySql Dumps using batch file ...: Too much ,, really in MYSQL finding complete solution like oracle & sql server is too difficult. That I have faced so many times with my d...

MYSQL:How to create MySql Dumps using batch file (WINDOWS)


Too much ,, really in MYSQL finding complete solution like oracle & sql server is too difficult. That I have faced so many times with my development team. One of my colleague asked about the dumps creation using batch file. Really I searches many sites on internet with unexpected   results. Taking dumps using command line I have already post on my blog , but in this case I need a batch file for execution. And finally when I prepare it for serve , I was really happy and now I am sharing this happiness with all my visitors .  Below the code inside the batch file :-

cd "c:\Program Files\MySQL\MySQL Server 5.0\bin\"
mysqldump -hyourIPaddress -uyour_user_name -pyour_password yourdbname > d:\output_backup.sql
exit


Now create a batch file and paste the code above with host,username, password,database name and output file name for store data.

Example 1:-
cd "c:\Program Files\MySQL\MySQL Server 5.0\bin\"
mysqldump -hlocalhost -uroot -proot manojdb > d:\mybackupdumps.sql
exit

If you want to take all database backup/dumps you can also do by following code :-

cd "c:\Program Files\MySQL\MySQL Server 5.0\bin\"
mysqldump -hlocalhost -umyuname -pmypassword --all-databases > d:\myalldatabasedumps.sql
exit


MYSQL Reference manual provides so many options for using with mysqldump . Some of the most useful are below :-


--add-locks  is used for    Surround each table dump with LOCK TABLES and UNLOCK TABLES statements.

 --all-databases  is used for Dump all tables in all databases.
  
 --comments  is used for Add comments to the dump file.

--compact is used for produce more compact out put .

--ignore-table=db_name.tbl_name is used for Do not dump the given table



You can also follow mysql reference manual for dumps creation  by Click Here. 



Hope it will help you.
Ping me always.

Manoj.Blog: MYSQL: Create database dump from command line (WIN...

Manoj.Blog: MYSQL: Create database dump from command line (WIN...: Hi Readers, Really in MYSQL/WINDOW, I have many obstacles and searches internet more than 7-8 hour for create a dump file of my database...

MYSQL: Create database dump from command line (WINDOWS)

Hi Readers,


Really in MYSQL/WINDOW, I have many obstacles and searches internet more than 7-8 hour for create a dump file of my database with compatible for all mysql db engines. And finally I fry some thing below: -

Steps-1 Go to your MYSQL installed directory inside bin
              C:\Program Files\MySQL\MySQL Server 5.0\bin
Steps-2 Use mysqldump command for create the backup.
              mysqldump -uyour_username -pyour_password your_databasename > D:\mybackup.sql

Steps-3 Press Enter


Now check your D drive and find the mybackup.sql file.


Hope it will help you.
Ping me always.

25 April, 2012

Manoj.Blog: HTML Marquee : set Stop and Play on mouse over an...

Manoj.Blog: HTML Marquee : set Stop and Play on mouse over an...: Hello readers, As you  marquee  can create a scrolling preview. But when we need to make some operation like mouse over ,mouse out etc. S...

HTML Marquee : set Stop and Play on mouse over and mouse out

Hello readers,

As you  marquee  can create a scrolling preview. But when we need to make some operation like mouse over ,mouse out etc. Stop & play of marque like below:-


<marquee  onmouseover="this.setAttribute('scrollamount',0,0);" onmouseout="this.setAttribute('scrollamount',6,0);">
<a  style="color: #FF0000" href="#" title="Notice">New notice for Marquee readers</a>
</marquee>


This above code will help you for stop and play on mouse over and mouse out respectively.


Hope it will help you.
Thankx

20 April, 2012

Manoj.Blog: Java : Get Last inserted ID (Auto Increment) from...

Manoj.Blog: Java : Get Last inserted ID (Auto Increment) from...: Really I faced lot of questions & problems related to this topic , basically when we are using mysql as the backend. But its quite obvious ...

Java : Get Last inserted ID (Auto Increment) from Database Query

Really I faced lot of questions & problems related to this topic , basically when we are using mysql as the backend. But its quite obvious & simple for find the last inserted record id (Auto increment ) and primary key also from an insert query ( Not from a procedure). I am not using callable statement for achieve this task. Simple directly by query :-

You can retrive value by using:-

1. select last_insert_id()
2. RETURN_GENERATED_KEYS


Follow the example below:-


String query="insert into m_time_list(vchTime,vchGMT,createdDate) values('"+form.getTxtTime()+"','"+form.getRdbgmt()+"',curdate())";
            pstmt=connection.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
            sts=pstmt.executeUpdate();   
            rs=pstmt.getGeneratedKeys();
            int sid=0;
            while(rs.next()){
                sid=rs.getInt(1);
            }

Now , Sid contains the return inserted ID.



Hope it will help you.
Ping me:
javadevelopersguide@blogspot.com


08 April, 2012

Manoj.Blog: Javascript : Password Validation with Regular expr...

Manoj.Blog: Javascript : Password Validation with Regular expr...: Hi viewers, This topic - Password Validation with Regular expression. Its a daily process for web developers to validating the passwo...

Manoj.Blog: FACEBOOK Link Integration to your Website. Share D...

Manoj.Blog: FACEBOOK Link Integration to your Website. Share D...: Copy the below given code inside your Html Page Tag and enjoy the facebook share plugin. <a name="fb_share" type="button"  share_...

How to validate Password with Regular expression.

In Today article,  we will see how to validate password with Regular expressionIts a daily process for web developers to validating the password with certain rules.With java script client side validate can be achieved. Below the code will help you to validate the password which contain at least one Letter , one Number & one special character. The password length must be within a given range.



/* Password must be at least one char, one special char & one digit & the length must be given*/
function validatePassword(pwdelem,alertmsg){
    var password_expression=/^((?=.*[a-zA-Z])(?=.*\d)(?=.*[#@%$]).{6,20})$/;
    if(pwdelem.value.match(password_expression)){
        return true;
    }
    else{
        alert(alertmsg);
        pwdelem.focus(); //Set focus to the given source element id ( textbox or password) ,it is optional .
        return false;
    }
}



30 December, 2011

FACEBOOK Link Integration to your Website

Copy the below given code inside your Html Page <Body> Tag and enjoy the facebook share plugin.

<a name="fb_share" type="button"  share_url="Your Website URL">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
        type="text/javascript">
</script>




Happy Learning. 

15 December, 2011

MYSQL User format ID Generation

Generate defined/User defined format Serial No from Database .There may be some condition where
I found this type of query which will help you to find the user format no from database.No. like
001 to 999 .


The Query for MySQL:

select case  when (intfield_id<=9 ) then concat('00',cast(intfield_id as CHAR))
when (intfield_id<=99 and intfield_id>9) then concat('0',cast(intfield_id as char)) when
(intfield_id<=999 and intfield_id>9 and intfield_id>99) then concat('0',cast(intfield_id as char))
end columnname from test




09 September, 2011

Manoj.Blog: Java Script : Drop Down values in JAVA SCRIPT

Manoj.Blog: Java Script : Drop Down values in JAVA SCRIPT: Hello , This function will help you to find the combo box / drop down box values in java script and again set these values to FORM. functio...

Java Script : Drop Down values in JAVA SCRIPT

Hello , This function will help you to find the combo box / drop down box values in java script and again set these values to FORM.

function setVal()
{
alert("sdf");
var innerData=document.getElementById('totData').innerHTML;
var hdtit=document.getElementById('hdsubtit').value;
var hdvalue=document.getElementById('hdsubval').value;
alert(hdtit);
//Getting Selected Index
var v=document.frmSubject.ddsub.selectedIndex;
//Getting Text & Value
var textdata=document.frmSubject.ddsub.options[v].text;
var val=document.frmSubject.ddsub.options[v].value;
//set the value to Form hidden Field
document.frmSubject.hdsubtit.value=hdtit+","+textdata;
document.frmSubject.hdsubval.value=hdvalue+","+val;
if(hdvalue==0){
document.getElementById('totData').innerHTML=innerData+" "+textdata;
}else{
document.getElementById('totData').innerHTML=innerData+" "+textdata;
}
}




Any Quries ....?

You may contact.

24 August, 2011

Java : Causes of An Out Of Memory Error (Server Si...

Manoj.Blog: Java : Causes of An Out Of Memory Error (Server Si...: Out Of Memory Error (OOME) can be solve. But what is actually it is !!!

The literal cause of an Out Of Memory Error is simple: a given To...

Java : Causes of An Out Of Memory Error (Server Side )

Out Of Memory Error (OOME) can be solve.But what is actually it is !!!



The literal cause of an Out Of Memory Error is simple: a given Tomcat instance uses up all of the heap memory allocated to it, causing an application or server crash.

Thus, the errors themselves are not particularly puzzling. The reason why OOMEs have become such a persistent topic of discussion in the Apache Tomcat community is that they are difficult to trace to their root cause.

A stack trace will not show the cause, as the problem usually lies not with Tomcat, but the web application.

Meanwhile, the 'incorrect' web app code causing Tomcat to run out of memory is usually technically correct. That is to say, in any context other than a container managed environment, the code would be considered standard. It is easy to see why a developer might have trouble determining which 'correct' section of their code was incorrect.

Here are some of the most common root causes of an OOME:

  • a simple case of the heap size being too small
  • running out of file descriptors
  • more open threads than the host OS allows
  • code with high amounts of recursion
  • code that loads a very large file into memory
  • code that retaining references to objects or classloaders
  • a large number of web apps and a small PermGen








Error: error java.lang.OutOfMemoryError: PermGen space..

Error: error java.lang.OutOfMemoryError: PermGen space..



In the area of J2EE development this error is one of the prominent & frequent which is not detected by any memory tool, so its interesting to avoid .PermGen space or heap size (outof memory) error can be avoided by following solutions.............

Solution-1
export CATALINA_OPTS=”-Xms512m -Xmx512m” (ksh/bash)
setenv CATALINA_OPTS “-Xms512m -Xmx512m” (tcsh/csh)

Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS=”-Xms512m -Xmx512m” (Windows)
In catalina.bat or catallina.sh, you may have noticed CATALINA_OPTS, JAVA_OPTS, or both can be used to specify Tomcat JVM options. What is the difference between CATALINA_OPTS and JAVA_OPTS? The name CATALINA_OPTS is specific for Tomcat servlet container, whereas JAVA_OPTS may be used by other java applications (e.g., JBoss). Since environment variables are shared by all applications, we don’t want Tomcat to inadvertently pick up the JVM options intended for other apps. I prefer to use CATALINA_OPTS.
Solution-2
Change the Catalina.bat file in Tomcat/bin with following code.
Edit catalina.bat.If you do not have catalina.bat , contact me.
If you have the .bat file, open and search for CATALINA_OPTS
If the parameter is set to no value, set it to -Xms256m -Xmx512m -XX:MaxPermSize=256m and move it to the top of the file.
If the above doesn’t work revoke the changes did in the previous step, go to the last lines of the catalina.bat. Look out for %_EXECJAVA% %JAVA_OPTS%. It will be in a few lines.
Insert the parameter in those lines. Like the one below.
%_EXECJAVA% %JAVA_OPTS% -Xms256m -Xmx512m -XX:MaxPermSize=256m %DEBUG_OPTS% -Djava.endorsed.dirs=”%JAVA_ENDORSED_DIRS%” -classpath “%CLASSPATH%” -Dcatalina.base=”%CATALINA_BASE%” -Dcatalina.home=”%CATALINA_HOME%” -Djava.io.tmpdir=”%CATALINA_TMPDIR%” %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
Here i have removed %CATALINA_OPTS% from them, to avoid setting parameters more than once.



It will really help you.I was in trouble with my team mates.
But now you can Enjoy...................