Sunday, June 29, 2014

Granting Mysql access from Azure Ubuntu server

It is assumed Mysql on the Ubuntu Vm has been installed
Set an endpoint for Mysql

Look for my.cnf and change the bind address. They should be in one of the following locations.
·         /etc/my.cnf
·         /etc/mysql/my.cnf
·         $MYSQL_HOME/my.cnf
·         [datadir]/my.cnf
·         ~/.my.cnf

#Replace 127.0.0.1 with your IP Address
bind-address        = 0.0.0.0
Now use Mysql as root and execute the command below
CREATE USER 'trustedUser'@'%' IDENTIFIED BY 'SomePassword';
GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES ON *.* TO 'trustedUser'@'%';


Afterwards, try to connect to mysql database.
mysql -h hostname.cloudapp.net -u trustedUser -p


Saturday, June 7, 2014

Notes On JSP

Well I have been using JSP for years and I below was my notes when I was a novice. Oh how they seemed silly now though they are correct.
Some old code I used as a novice

<% 
if(userProfile==null)
out.println(request.getParameter("Firstname")+" "+request.getParameter("surname"));
else out.println(userProfile.getFirstName()+" "+userProfile.getLastName());
%>


Special JSP tags

A JSP page consists of three kinds of elements, each with its own special markup tag
that’s similar to HTML:
Scriptlets—Java code executed when the page is loaded. Each of these state-
ments is surrounded by <%and %>tags.
Expressions—Java expressions that are evaluated, producing output displayed on
the page. These are surrounded by <%= and %>tags.
Declarations—Statements to create instance variables and handle other setup tasks

required in the presentation of the page. These are surrounded by  <%! and %>tags.

Servlet objects used in Expressions

There are several servlet objects you can refer to in expressions and other elements of a
JSP page using the following variable names:
 out —The servlet output stream
 request—The HTTP servlet request
 response —The HTTP servlet responses
session—The current HTTP session
application —The servlet context used to communicate with the web server
config —The servlet configuration object used to see how the servlet was initialized