Ticker

6/recent/ticker-posts

Advertisement

JSP flow control statements in hindi

     JSP flow control statements 

    कन्ट्रोल फ्लो स्टटेमेन्ट्स JSP की   सहायता से हम अपनी  वेब एप्लीकेशन में जावा को   को पूर्ण रूप से प्रयोग कर सकते हैं  हम अपनीJSP Programming में जावा की  समस्त API और  डिसिशन मेकिंग स्टटेमेन्ट्स, Loops  आज का प्रयोग कर सकते हैं |

    Decision Making Statements 

    Decision Making Statements जैसे कि हम जानते हैं डिसिशन मेकिंग के लिए, दो Statements if...... else और switch....... case का  प्रयोग किया जाता है I

    if....else :

     ब्लॉक  का  आरम्भ  किसी भी सामान्य स्क्रिपलेट  की तरह होता है परंतु स्क्रिपलेट को  प्रत्येक लाइन पर HTML Text के Close करना होता हैं

    Syntax 

    <% if (Condition ) {%>
          task if true 
    <%}elsev{%>
    <%}%>

    if..else Code Example 

    <%! int day =3;%>
    <html>
    <head> <title> IF...ELSE Example</title> </head>
    <body>
    <% if (day ==1| day= = 7){%>
    <p> Today is weekend </p>
    <%} else {%>
    <p> Today is not weekend </p>
    <%}%>
    </body>
    </html>


    Output : Today is weekend 

    switch.....case 

    ब्लॉक का सामान्य  रूप  से ही बनाया जाता है  1


    इसका  सिन्टैक्स   Syntax 

    <%switch (Variable ) {
    case:
    task1
    case:
    default:}%>

    switch ....case  Code Example

    <%! int day =3;%>
    <html>
              <head> <title > Switch ......Case Example </title > </head>
    <body>
    <%
           switch( day) {
    case 0:
               out.println (" IT\,s Sunday .");
    break;

    case 1:
              out.println("IT\ ,s Monday.");
    break ;

    case 2:

              out.println("IT\ ,s Tuesday ");
    break;

    case 3:
             out.printin("IT\ ,s Wednesday.");

    break;

    case 4:
             out.printin("IT\ ,s Thursday .");
    break;

    case 5:
            out.printin("IT \,s Friday.");
    break;

    default:
              out.println("IT ,s Saturday.");
    }

    %>
    </body>
    </html>



    Output : IT,s Wednesday.


    Loop Statements 


    जावा के तीनों  लूप्स  for ,while , और do...while  का प्रयोग  हम अपनी JSP pargramming  में कर सकते हैं इन तीनों लूप्स को सामान्य रूप से ही  प्रयोग किया जाता हैं 1

    for loop   


    for loop इसका  सिन्टैक्स   Syntax 


    <% for (initiatization ; condition ;increments / decrement)
    {%>
    <task to do>
    <%}%>

    for loop Code Example 

    <%! intfontSize; %>
    <html>
          <head> <title> For Loop Example </title> </head.>
    <body>
              <%for (fontSize = 1; font Size <=3;font Size++){%>
    <font ccolor="black" size="<%=fontSize %>">
    This is a foor loop
    </font > <br/>
    <%}%>
    </body>
    </html>



    Output :
    This is a foor loop

    This is a foor loop

    This is a foor loop

    While Loop :


    इसका  सिन्टैक्स   Syntax 


    <% initialization %>

    <% while (condition) { %>
          <task to do >
    <% increment / decrement%>
    <%}%>

    while Loop Code Example 

    <%! int font Size ;%>
    <html>
           <head> <title> WHILE Loop Example </title > </head>
    <body>
               <%while ( font Size < =3) { %>
    <font color= "red" size="<%= fontSize %>">
    This is a whie loop
    <font Size ++;%>
    <%}%>
    </body>
    </html>

        Oouput :

    This is a foor loop

    This is a foor loop

    This is a foor loop

    do ....while 


    इसका  सिन्टैक्स   Syntax 

    <% initialization %>

    <%do {%>
    <task to do >
    <%incremet / decrement %>
    <%} while ( condition ) %>



    do....while Loop Code Example 


    <%! int font Size ;%>
    <html>
           <head> <title> DO WHILE Loop Example </title > </head>
    <body>
    <%do{%>
               
    <font color= "red" size="<%= fontSize %>">
    This is a whie loop
    </font > <br/>
    <%while ( font Size < =3) { %>
    </body>
    </html>

     Oouput :

    This is a foor loop

    This is a foor loop

    This is a foor loop

    एक टिप्पणी भेजें

    0 टिप्पणियाँ