Showing posts with label brecw. Show all posts
Showing posts with label brecw. Show all posts
Thursday, 26 October 2017
Sunday, 3 September 2017
How to compile and run from EditPlus
EditPlus is a Windows text editor with built-in FTP (also FTPS) and sftp capabilities. While it can serve as a good Notepad replacement, it also offers many powerful features for Web page authors and programmers.
Syntax highlighting for HTML, PHP, Java, C/C++, CSS, ASP, Perl, JavaScript, VBScript, Python and Ruby on Rails. Also, it can be extended for other programming languages based on custom syntax files.
Seamless Web browser for previewing HTML pages, and FTP (also sftp and FTPS) feature for uploading local files to FTP server.
After installation
4.Add one more tool to run your java programs with the following arguments shown in picture below.
5.Inorder to test the tools create a new java file as shown below
6. go to tools to see the newly added user defined tools with their shortcuts
7. To compile your code press ctrl+1 and to run press ctrl+2
Once you run the code output is automatically shown on command prompt.
Sunday, 20 August 2017
Monday, 14 August 2017
Netbeans installation
NetBeans IDE is the official IDE for Java 8. With its editors, code analyzers, and converters, you can quickly and smoothly upgrade your applications to use new Java 8 language constructs, such as lambdas, functional operations, and method references.
Batch analyzers and converters are provided to search through multiple applications at the same time, matching patterns for conversion to new Java 8 language constructs.
With its constantly improving Java Editor, many rich features and an extensive range of tools, templates and samples, NetBeans IDE sets the standard for developing with cutting edge technologies out of the box.
Download Netbeans IDE 8.2
Once the exe file gets downloaded double click on it to proceed with installation
Accept the license agreement and then click next
Specify the location of jdk and the drive where you want to install netbeans.By default it takes C drive as location
Specify the location to install Glassfish server
Oracle GlassFish ServerOracle GlassFish Server is the world's first implementation of the Java Platform, Enterprise Edition (Java EE) 6 specification. Built using the GlassFish Server Open Source Edition, Oracle GlassFish Server delivers a flexible, lightweight, and production-ready Java EE 6 application server. | ||
To run the program right click on java application project and click run.You can see the output in Output screen
Monday, 10 April 2017
calculator database using php
Hi all this post explains implementation of calculator database in php
you are required to write the following set of instructions here.
<TITLE>PHP Calculator v1</TITLE>
<form name="calc" action="?page=calc" method="POST"> <!--implementing pagination with the page name appended to url -->
Number 1: <input type=text name=value1><br>
Number 2: <input type=text name=value2><br>
Operation: <input type="submit" name=oper value="add"/> <input type="submit" name=oper value="subtract"/>
<input type="submit" name=oper value="divide"/> <input type="submit" name=oper value="multiply"/><br>
</form>
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST')//checking if the form method is post
{
$page = $_GET['page'];
// Defining the "calc" class
class calc {
var $number1; //variable declaration
var $number2;
function add($number1,$number2) {
$con=db(); //creating connection variable
$result =$number1 + $number2;
echo("The sum of $number1 and $number2 is $result<br><br>");
echo("$number1 + $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 + $number2',$result)");
exit;
}
function subtract($number1,$number2) {
$con=db();
$result =$number1 - $number2;
echo("The difference of $number1 and $number2 is $result<br><br>");
echo("$number1 - $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 - $number2',$result)");
exit;
}
function divide($number1,$number2) {
$con=db();
$result =$number1 / $number2;
echo("$number1 divided by $number2 is $result<br><br>");
echo("$number1 ÷ $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 / $number2',$result)");
exit;
}
function multiply($number1,$number2) {
$con=db();
$result =$number1 * $number2;
echo("The product of $number1 and $number2 is $result<br><br>");
echo("$number1 x $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 * $number2',$result)");
exit;
}
}
$calc = new calc();
?>
<?php
if($page == "calc"){
$n1 = $_POST['value1'];
$n2 = $_POST['value2'];
$number1=abs(ltrim($n1,''));
$number2=abs(ltrim($n2,''));
$oper = $_POST['oper'];
function db () {
static $con;
if ($con===NULL){
$con = mysqli_connect ("localhost", "root", "", "plus");
}
return $con;
}
if(!$number1){
echo("You must enter number 1!");
exit;
}
if(!$number2){
echo("You must enter number 2!");
exit;
}
if(!$oper){
echo("You must select an operation to do with the numbers!");
exit;
}
if(!preg_match("/[0-9]/", $number1)){
echo("Number 1 MUST be numbers!");
exit;
}
if(!preg_match("/[0-9]/", $number2)){
echo("Number 2 MUST be numbers!");
exit;
}
if($oper == "add"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 + $number2'");
if (!$query) {
echo 'MySQL Error: ' . mysqli_error();
exit;
}
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->add($number1,$number2);
}
}
if($oper == "subtract"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 - $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->subtract($number1,$number2);
} }
if($oper == "divide"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 / $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->divide($number1,$number2);
}
}
if($oper == "multiply"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 * $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->multiply($number1,$number2); } }
while ($row = mysqli_fetch_assoc($query)) {
print("Accessed from database.......<br>");
print($row['exp'] . " = " . $row['res']);
}
}
}
?>
you are required to write the following set of instructions here.
<TITLE>PHP Calculator v1</TITLE>
<form name="calc" action="?page=calc" method="POST"> <!--implementing pagination with the page name appended to url -->
Number 1: <input type=text name=value1><br>
Number 2: <input type=text name=value2><br>
Operation: <input type="submit" name=oper value="add"/> <input type="submit" name=oper value="subtract"/>
<input type="submit" name=oper value="divide"/> <input type="submit" name=oper value="multiply"/><br>
</form>
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST')//checking if the form method is post
{
$page = $_GET['page'];
// Defining the "calc" class
class calc {
var $number1; //variable declaration
var $number2;
function add($number1,$number2) {
$con=db(); //creating connection variable
$result =$number1 + $number2;
echo("The sum of $number1 and $number2 is $result<br><br>");
echo("$number1 + $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 + $number2',$result)");
exit;
}
function subtract($number1,$number2) {
$con=db();
$result =$number1 - $number2;
echo("The difference of $number1 and $number2 is $result<br><br>");
echo("$number1 - $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 - $number2',$result)");
exit;
}
function divide($number1,$number2) {
$con=db();
$result =$number1 / $number2;
echo("$number1 divided by $number2 is $result<br><br>");
echo("$number1 ÷ $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 / $number2',$result)");
exit;
}
function multiply($number1,$number2) {
$con=db();
$result =$number1 * $number2;
echo("The product of $number1 and $number2 is $result<br><br>");
echo("$number1 x $number2 = $result");
mysqli_query($con,"insert into plus values('$number1 * $number2',$result)");
exit;
}
}
$calc = new calc();
?>
<?php
if($page == "calc"){
$n1 = $_POST['value1'];
$n2 = $_POST['value2'];
$number1=abs(ltrim($n1,''));
$number2=abs(ltrim($n2,''));
$oper = $_POST['oper'];
function db () {
static $con;
if ($con===NULL){
$con = mysqli_connect ("localhost", "root", "", "plus");
}
return $con;
}
if(!$number1){
echo("You must enter number 1!");
exit;
}
if(!$number2){
echo("You must enter number 2!");
exit;
}
if(!$oper){
echo("You must select an operation to do with the numbers!");
exit;
}
if(!preg_match("/[0-9]/", $number1)){
echo("Number 1 MUST be numbers!");
exit;
}
if(!preg_match("/[0-9]/", $number2)){
echo("Number 2 MUST be numbers!");
exit;
}
if($oper == "add"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 + $number2'");
if (!$query) {
echo 'MySQL Error: ' . mysqli_error();
exit;
}
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->add($number1,$number2);
}
}
if($oper == "subtract"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 - $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->subtract($number1,$number2);
} }
if($oper == "divide"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 / $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->divide($number1,$number2);
}
}
if($oper == "multiply"){
$con=db();
$query = mysqli_query($con,"SELECT * FROM plus WHERE exp='$number1 * $number2'");
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
$calc->multiply($number1,$number2); } }
while ($row = mysqli_fetch_assoc($query)) {
print("Accessed from database.......<br>");
print($row['exp'] . " = " . $row['res']);
}
}
}
?>
Sunday, 19 March 2017
USING PREPARED STATEMENT IN JSP
The PreparedStatement interface is a subinterface of Statement. It is used to execute parameterized query.
Improves performance: The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
Create emp_table in mysql as follows:
This is the output for your jsp:
Improves performance: The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
Following is the example implementing the same interface in jsp:
In this jsp execution you are not required to explicitly keep mysqlconnector.jar as it should be present in tomcats lib folder like below:
Create emp_table in mysql as follows:
This is the output for your jsp:
Friday, 17 March 2017
JSP AGE VALIDATION ALONG WITH CSS
A web application that takes name and age from an HTML page. If the age is less than 18 it should send a page with “Hello <name>, you are not authorized to visit the site “message, where <name> should be replaced with the entered name. Otherwise it should send “Welcome <name> to this site “message.
Below is the folder structure that is to be followed for every tomcat application
The html form nameage consist of the link to stylesheet along with the form details:
This is the jsp code for processing age criteria:
Once you start your application in tomcat automatically the corresponding class and java files are generated in the below folder:
Following are the output screens where in based on the age criteria the user will be prompted with the respective messages:
Subscribe to:
Posts (Atom)






