Home Answers Viewqa JSF-Questions do the following

 
 


mayur patel
do the following
7 Answer(s)      4 months and 9 days ago
Posted in : Java Server Faces Questions

write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6- convert third word in lowercase

View Answers

June 12, 2013 at 4:48 PM


hi friend,

Try the following code, may this will be helpful for you

index.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>Index Page Example</title>
</head>
<body>
<table>
<tr>
<td><h:link value="Get No Of Vowels" outcome="vowel" /></td>
</tr>
<tr>
<td><h:link value="Get Reverse String" outcome="reverse" /></td>
</tr>
<tr>
<td><h:link value="Change Character In Upper Case" outcome="upperText" /></td>
</tr>
<tr>
<td><h:link value="Change Character In Lower Case" outcome="lowerText" /></td>
</tr>
<tr>
<td><h:link value="Delete Character" outcome="delete" /></td>
</tr>
</table>
</body>
</html>

Continue...


June 12, 2013 at 4:49 PM


vowel.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Count Vowel Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter String To Check Vowel : </td>
<td><h:inputText id="nameText" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15" accesskey="t"/></td>
<td><h:message for="nameText" style="color:red" /></td>
</tr>
<tr>
<td>Total No Of Vowels Are : </td>
<td><h:outputText value="#{vowel.count}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Vowel Count" action="#{vowel.getVowel(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...


June 12, 2013 at 4:50 PM


reverse.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Reverse String Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Reverse : </td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String After Reverse : </td>
<td><h:outputText value="#{vowel.revString}"/></td>
</tr>
<tr>
<td><h:commandButton value="Reverse Value" action="#{vowel.reverseString(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...


June 12, 2013 at 4:52 PM


upperText.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Upper Text Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Convert In Upper Case 
<table>
<tr>
<td>(Second Word Should Be In Lower Case)</td>
</tr>
</table>
</td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String In Upper Case : </td>
<td><h:outputText value="#{vowel.strUpper}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Upper" action="#{vowel.upper(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...


June 12, 2013 at 4:58 PM


lowerText.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Lower Text Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Convert In Lower Case 
<table>
<tr>
<td>(Third Word Should Be In Upper Case)</td>
</tr>
</table>
</td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String In Lower Case : </td>
<td><h:outputText value="#{vowel.strLower}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Lower" action="#{vowel.lower(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...


June 12, 2013 at 5:00 PM


delete.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Delete Character Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String : </td>
<td><h:inputText id="text2" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text2" style="color:red" /></td>
</tr>
<tr>
<td>Enter Character To Delete : </td>
<td><h:inputText id="text1" value="#{vowel.ch1}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15" accesskey="c"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String After Delete</td>
<td><h:outputText value="#{vowel.str1}"/></td>
</tr>
<tr>
<td><h:commandButton value="Delete Character" action="#{vowel.deleteChar(vowel.ch1)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...


June 12, 2013 at 5:01 PM


FindVowel.java

package devmanuals;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="vowel")
@RequestScoped
public class FindVowel {

    String str, str1, revString="", strUpper="", strLower="";

    int count=0;
    char ch;
    char ch1, ch2;

    public String getStrLower() {
        return strLower;
    }

    public String getStrUpper() {
        return strUpper;
    }

    public String getRevString() {
        return revString;
    }

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        this.str = str;
    }

    public int getCount()
    {
        return count;
    }

    public String getStr1()
    {
        return str1;
    }

    public char getCh1() {
        return ch1;
    }

    public void setCh1(char ch1) {
        this.ch1 = ch1;
    }

    public void lower(String str2)
    {
        //String newString="";
        StringBuffer sb = new StringBuffer();
        for(int i=0; i < str2.length(); i++)
        {
            //System.out.println(i+" "+str2.charAt(i));
            //str2.charAt(i);
            if(i < 2)
            {
            sb.append(str2.charAt(i));
            }
            if(i==2)
            {
                char c = str2.charAt(i);
                String u = Character.toString(c);
                sb.append(u.toLowerCase());             
            }
            if(i > 2)
            {
                sb.append(str2.charAt(i));
            }
        }
        strLower = sb.toString();       
    }   

    public void upper(String str2)
    {
        //String newString="";
        StringBuffer sb = new StringBuffer();
        for(int i=0; i < str2.length(); i++)
        {
            //System.out.println(i+" "+str2.charAt(i));
            //str2.charAt(i);
            if(i < 1)
            {
            sb.append(str2.charAt(i));
            }
            if(i==1)
            {
                char c = str2.charAt(i);
                String u = Character.toString(c);
                sb.append(u.toUpperCase());             
            }
            if(i > 1)
            {
                sb.append(str2.charAt(i));
            }
        }
        strUpper = sb.toString();       
    }

    public void reverseString(String str2)
    {       
        for(int i=str2.length()-1; i >= 0; i--)
        {
            revString = revString+str2.charAt(i);           
        }       
    }

    public void deleteChar(char c)
    {
        if(c != 0)
        {
            for(int i=0; i< str.length(); i++)
            {
                ch2 = str.charAt(i);
                if(c == ch2)
                {
                    str1 = str.replace(""+c, "");
                }
            }
        }       
    }

    public void getVowel(String text)
    {       
        if(text != null)
        {                   
            for(int i = 0; i< text.length(); i++)
            {
                ch = text.charAt(i);
                if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' ||
                    ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
                {
                    count++;
                }
            }       
        }
    }   
}

Thanks.









Related Pages:
do the following
do the following  write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6
Write a program named InternetCharge_YourLastName that do the following:
Write a program named InternetCharge_YourLastName that do the following: ..._YourLastName that do the following: *display the menu as follow: 1. Package A 2... the total charge in the following format. The total charge will include the tax 8.5
The while and do
While and do-while      ... a particular condition is true. To write a while statement use the following form... that the condition becomes false and the loop terminates. Have a look at do
how to do this?
how to do this?   Given any integer 2D array, design then implement a Java program that will add to each element in the array the corresponding... and after modification. For example, if the program fed with following 2D array
write following program
write following program  Q1 What is the difference between single threaded application and multithreaded application? What are the benefits of multi... between applet and HTML? Q13 How do you add a class or an interface to a package
do-while loop
do-while loop  how many times will the following loop get executed and what will be the final value of the variable I after execution the loop is over. int I = 5; do{ I + = 3; System.out.println(""+I); I=I+1; }while(I>=9
While and do-while
While and do-while      ... then we have to write down the following line... the following classes: class OuterClass {   ...   class InnerClass
error occured in following page ... how to resolve it?
error occured in following page ... how to resolve it?  // to convert image into thumbnail i used following code. But netbeans has given me following error ....wht i shud do???????? i m java beginner so plz explain in smooth way
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
how I do select from select in hql
how I do select from select in hql  select RN from ( select rownum RN, dbid from ( select * from profile p where type = 1912 and name like... by p.profileKey.name ) ) where DBId = ?   Please visit the following
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... will look like after perform each of the following sequence of events: a. start
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... will look like after perform each of the following sequence of events: a. start
how do i use sql like query in my jsp page
how do i use sql like query in my jsp page  how do i use sql like query in my jsp page   Hi Friend, Try the following code: <%@ page import="java.sql.*"%> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
I wanted do develop mini application With server request and tesponse
I wanted do develop mini application With server request and tesponse  I m planning to develop the mini webapplication using struts 1.2.9... first step please   Please go through the following links: http
Use if, if else,for,while,do wile ad switch in same Java Class
Use if, if else,for,while,do wile ad switch in same Java Class  hi how to use if, if else,for,while,do wile ad switch in same class? very urgent... "); System.out.println("5. Exit"); boolean quit = false; do{ System.out.print("Please
source code for the following question
source code for the following question  source code for the fuzzy c-means
Print the following format
Print the following format  how to print the following format given string "00401121" in java 0-** 1-* 2-* 3- 4
Expain the following code ?
Expain the following code ?  please explain the following line of code clearly? <html:link href="user.do?parameter=create">Create User</html:link>
covert the following using java
covert the following using java  how to convert (for eg : 2.89) . this decimal to binary in java
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
print the following series
print the following series  a b c d e b c d e c d e d e e   Hi Friend, Try the following code: class StringPattern { public static void main(String[] args) { String st="abcde
print array in following format
print array in following format  i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19 i...; Here is a code that displays the array values in the following pattern: 1 2
how to print the following pattern
how to print the following pattern  Hello hEllo heLlo helLo hellO pls reply soon its an emergency   class StringPattern { public static void main(String[] args) { String st="hello
While and do-while
While and do-while      ... condition is true. To write a while statement use the following form: while... at do-while statement now. Here is the syntax: do { statement(s
Fashion Accessories: Why do you need them?
Fashion Accessories: Why do you need them? It is pretty obvious why you would want decent looking clothes, maybe even following the current trends, but the need for all sorts of fashion accessories doesn't come as a simple idea
Fashion Trends: Why do we follow them?
Fashion Trends: Why do we follow them? We all hear about the new fashion trends and we always wonder, why do some people follow these trends so strictly... about. The latest's Fashion trends change regularly, so if you plan on following
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
Java errors when attempting the following.
Java errors when attempting the following.  Give the java errors in attempting the following : 1) performing division operation on string value. 2) redefining base class final method in derived class. 3) defining a method
Need the Following MobileApplication Related Code
Need the Following MobileApplication Related Code  Hi, I need java coding for the following requirements in Collections.. Mobile Subscriber name: Subscriber PhonNo: Add the Subscriber: Update the Subscriber
How to print the following pattern in java?
How to print the following pattern in java?  How to print the following pattern in java? he he is he is going he is going in   import java.io.*; class StringPattern { public static void main(String[] args
Please provide coding for following problem
Please provide coding for following problem  Please provide the coding for the following problem: You will write a java program that will read data from a file. The data in the file will be: John Doe 75 Joe Blow 65 Mary Smith 80
how to do dynamic ally placeholder using properties or some else - JSP-Servlet
how to do dynamic ally placeholder using properties or some else   dear sir, how to use and declare a dynamic place holder in java? i have to send the following mail Dear [Column 1] Your Bonus is [column 2]. Thanks
I am new to programming and I am not sure what to do next? Any ideas?
I am new to programming and I am not sure what to do next? Any ideas? ...); static Random rand = new Random(); // The following routine will determin... contains "ard" and strToGuess contains "aardvark" then // the following
php do while syntax
php do while syntax  How to create a do while loop in php. What is the syntax
php do while example
php do while example  Simple example of do while loop in PHP
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
Use of "following" in XPath
Use of "following" in XPath   ... will select each and every node or element following this current node closing...;XPathFactory.newInstance().newXPath(); Expression "//person/following
while and do while
while and do while  hello, What is the difference between a while statement and a do statement?   hello, A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
php do while false
php do while false   Is there any difference between FALSE and false
Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the sessio
Identify the interface and method for each of the following... for reuse following passivation, release resources prior to removal, identify... for each of the following: retrieve the session bean's remote home interface
What does COMMIT do?
What does COMMIT do?  What does COMMIT do?   Hi, here is the answer, COMMIT makes permanent the changes made by DML statements in the transaction. The changes made by the DML statements of a transaction become
Dont Do this - Java Beginners
Dont Do this  Whenever you guys ask a question please describe your query? Otherwise you lost your time and other who are given answer to you. thanks Rajanikant