Posts

Showing posts from November, 2016

JSP Example to create custom tag that will append a String to its own body and will display the result

JSP Example   to create custom tag that will append a String to its own body and will display the result Details.java package beginnersbook . com ; import javax . servlet . jsp . tagext .*; import javax . servlet . jsp .*; import java . io .*; public class Details extends SimpleTagSupport {    //StringWriter object    StringWriter sw = new StringWriter ();      public void doTag () throws JspException , IOException    {        getJspBody (). invoke ( sw );        JspWriter out = getJspContext (). getOut ();        out . println ( sw . toString ()+ "Appended Custom Tag Message" );    } } TLD file:   message.tld Remember to have this file in WEB-INF folder. <taglib> <tlib-version> 1.0 </tlib-version> <jsp-version> 2.0 </jsp-version> <short-name> My Custom Tag: MyMsg </short-name> <tag> <name> MyMsg </name> <tag-class> beginnersbook.com.Details </tag-class>

JSP Example to fetch Value using param variable of expression language

JSP Example  to fetch Value  using param variable of expression language  index.jsp <html> <head> <title> Expression language example2 </title> </head> <body> <form action = "display.jsp" > Student Name: <input type = "text" name = "stuname" /><br> Student RollNum: <input type = "text" name = "rollno" /><br> <input type = "submit" value = "Submit Details!!" /> </form> </body> </html> display.jsp <html> <head> <title> Display Page </title> </head> <body> Student name is ${ param.stuname } <br> Student Roll No is ${ param.rollno } </body> </html>

JSP Example for Exception implicit Object

JSP Example  for Exception implicit Object  index.html <html> <head> <title> Enter two Integers for Division </title> </head> <body> <form action = "division.jsp" > Input First Integer: <input type = "text" name = "firstnum" /> Input Second Integer: <input type = "text" name = "secondnum" /> <input type = "submit" value = "Get Results" /> </form> </body> </html> division.jsp <%@ page errorPage = "exception.jsp" %> <% String num1 = request . getParameter ( "firstnum" ); String num2 = request . getParameter ( "secondnum" ); int v1 = Integer . parseInt ( num1 ); int v2 = Integer . parseInt ( num2 ); int res = v1 / v2 ; out . print ( "Output is: " + res ); %> exception.jsp <%@ page isErrorPage = "true" %> Got this Ex

JSP Example for Session Implicit Object

Image
JSP Example  for Session Implicit Object  index.html <html> <head> <title> Welcome Page: Enter your name </title> </head> <body> <form action = "session.jsp" > <input type = "text" name = "inputname" > <input type = "submit" value = "click here!!" ><br/> </form> </body> </html> The   session.jsp   page displays the name which user has entered on the index page and it stores the same variable in the   session object   so that it can be fetched on any page until the session becomes inactive. session.jsp <html> <head> <title> Passing the input value to a session variable </title> </head> <body> <% String uname = request . getParameter ( "inputname" ); out . print ( "Welcome " + uname ); session . setAttribute ( "sessname" , uname ); %> <a

JSP Example for Request Implicit Object

JSP Example  for Request Implicit Object   . index.html <html> <head> <title> Enter UserName and Password </title> </head> <body> <form action = "userinfo.jsp" > Enter User Name: <input type = "text" name = "uname" /> <br><br> Enter Password: <input type = "text" name = "pass" /> <br><br> <input type = "submit" value = "Submit Details" /> </form> </body> </html> userinfo.jsp <%@ page import = " java.util.* " %> <html> <body> <% String username = request . getParameter ( "uname" ); String password = request . getParameter ( "pass" ); out . print ( "Name: " + username + " Password: " + password ); %> </body> </html>

Yuvraj Singh-Hazel Keech wedding on November 30

A cricketer Yuvraj Singh and model-turned-actress Hazel Keech all set to tie the nuptial knot on November 30, adequate arrangements are being made at spiritual Dera of Baba Ram Singh Ganduan Wale in village Duffera here where the couple will get the blessings of Dera Head Baba Ram Singh.

JSP Example for OUT Implicit Object

JSP Example  for OUT Implicit Object <HTML> <HEAD> <TITLE> OUT IMPLICIT OBJECT EXAMPLE </TITLE> </HEAD> <BODY> <% out . print ( "print statement " ); out . println ( "println" ); out . print ( "Another print statement" ); %> </BODY> </HTML>

Method sum using JSP declaration tag

Method sum using JSP declaration tag <html> <head> <title> Methods Declaration </title> </head> <body>    <%!    int sum ( int num1 , int num2 , int num3 ){    return num1 + num2 + num3 ;    }   %>    <%= "Result is: " + sum ( 10 , 40 , 50 ) %> </body> </html>

JSP two variables inside declaration tag and display them on client using expression tag.

  Two variables inside declaration tag and display them on client using  expression tag . <html> <head> <title> Declaration tag Example1 </title> </head> <body> <%! String name = "Chaitanya" ; %> <%! int age = 27 ; %> <%= "Name is: " + name %> <br> <%= "AGE: " + age %> </body> </html>

JAVA SERVER PAGES

JAVA SERVER PAGES EXAMPLE <%-- JSP comment --%> <HTML> <HEAD> <TITLE> MESSAGE </TITLE> </HEAD> <BODY> <% out . print ( "Hello, Sample JSP code" );%> </BODY> </HTML>

OnePlus 3T launch on Dec 2 in India

Image
The new version of the flagship killer from the Chinese technology start-up will launch in India on December 2. The company revealed the same in the  Facebook  video dare featuring its India General Manager Vikas Agarwal. OnePlus 3T was launched this month, and the phone went on sale in US, Europe, UK markets on November 22. OnePlus 3T marks a jump in the processor, front camera, and battery compared to the earlier flagship. The front camera is also 16MP in the OnePlus 3T smartphone, which is a bump from the 8MP front camera on the earlier version of the smartphone. Battery in the OnePlus 3T is 3,400 mAh (non-removable). OnePlus 3 has a 3000 mAh battery in comparison, so this one could last longer than the earlier phone. OnePlus has also added its Dash Charge support, which promises a day’s worth of battery life in just 30 minutes of charge. OnePlus 3 is priced at Rs 27,999 and while it has been discontinued in other markets like EU, US, etc there’s no word on whether the compan