Monday, February 17, 2020

Deploying a basic web app in tomcat server.


Install Tomcat 9.
 
Edit username and password to use in tomcat-users.xml

Create a web app with name 'MyTestWebApp' in eclipse photon.
Give path of tomcat server root directory & JDK / JRE.

Create a welcome page for the app named 'welcomePage.html'.
Mention the name of this page in web.xml <welcome-page> tag.

Create a servlet with name 'MyServlet.java'

Export .war of the project created.

Access https://localhost:8080
Click on manager button.
Login using username and password mentioned in tomcat-users.xml
Deploy .war in tomcat server.

Start tomcat server by running command startServer.bat 

Access following URL in browser:- https://localhost:8080/MyTestWebApp/welcomePage.html


Sunday, January 26, 2020

Python 3

Python 3 Programming language is simple in syntax & interpreter based.
It is used in data science, AI, ML due to it's easy to understand syntax.

Tuesday, October 8, 2013

BIRT FAQ's

1.] How to remove decimal point and the digits after decimal on report?

-- Select the field of number value. Go to its properties section, select Format Number in it. 
Select Format as field as Custom and Format Code as ##,##,##0 instead of ##,##,##0.00

2.] The BIRT report shows year as 2014 even though the value is 2013.

-- Change the date format from YYYY to yyyy.

Friday, September 27, 2013

Installing BIRT in STS



1) Install STS 

2) Click on help -
Install New Software --> Click on Add
-> give the URL (http://download.eclipse.org/birt/update-site/4.2/)

3) Select the BIRT components you want to install--> click Next and follow the instructions such as accept terms and conditions.

4) Click on Finish, it will start installing the BIRT components.

5) It is getting installed successfully and we can see the version details on the following path: Help-
About STS
-> click on Eclipse BIRT Project

Thursday, September 26, 2013

Cookies using JSP / Servlet

Login.jsp

<form action="rem" method="POST">
Enter Value: <input type="text" name="val" value=""/>
<input type="submit" value="Submit" />
</form>

----------------------------------------------------------------------------------
RemController.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String myValue = request.getParameter("val");


    Cookie userCookie = new Cookie("u", myValue);
        userCookie.setMaxAge(60*60*24);
        response.addCookie(userCookie);


    request.getRequestDispatcher("Remember.jsp").forward(request, response);
    }
----------------------------------------------------------------------------------
Remember.jsp

<html>
 <%
        Cookie[] cookies=request.getCookies();
        Cookie cookie=null;
        if(cookies != null){
            for(int i=0; i<cookies.length; i++){
                cookie = cookies[i];
                System.out.print(cookie.getName()+": ");
                System.out.println(cookie.getValue());
            }
        }
        %>
</html>
----------------------------------------------------------------------------------

Wednesday, September 25, 2013

Login Page using Servlet / JSP

1. Servlet Mapping in web.xml

Transfering control from JSP (Login.jsp) file to a servlet (RemController.java) file.
 ----------------------------------------------------------------------------------------------------------------------------
Login.jsp

<form action="rem" method="POST">
Username: <input type="text" id="username" name="username" value=""/><br/>
Password: <input type="password" id="password" name="password" value=""/><br/>
<input type="submit" id="submit" value="Submit" /><br/>

</form>
----------------------------------------------------------------------------------------------------------------------------
web.xml

 <servlet>
    <servlet-name>RemController</servlet-name>
    <servlet-class>myPkg.RemController</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>RemController</servlet-name>
    <url-pattern>/rem</url-pattern>
  </servlet-mapping>
----------------------------------------------------------------------------------------------------------------------------
RemController.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("result", "hello!");
      
        String name = request.getParameter("username");
        String password = request.getParameter("password");
      
        System.out.println(name+" "+password);
      
    //    response.sendRedirect("Remember.jsp");
        request.getRequestDispatcher("Remember.jsp").forward(request, response);
        }
----------------------------------------------------------------------------------------------------------------------------
Remember.jsp

<html>
<body>
        <h1>Remember.jsp</h1>
        <p>The result is ${result}</p>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------

Wednesday, September 4, 2013

Database FAQ's

Finding Non-unique rows.

SELECT LIC_NO, count(LIC_NO) AS cnt FROM LM_LICENSE GROUP BY LIC_NO HAVING cnt>1;