Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSF-Questions do the following

Have Programming Question? Ask it here!
 
 
 


mayur patel
do the following
7 Answer(s)      a year and 6 months 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


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334 4322234 4321234 4322234 4333334 4444444 // for input 4. And also
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
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
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
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
How to do url rewritting?
How to do url rewritting?  Dear Sir/Mam I have this link http://localhost:8085/call4admission/admin/home/Admin... to do?Please suggest
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
Do needful - Java Beginners
Do needful  Hai how can I do the string to Hex in java. Pls help me  use conversion concept  Hi friend, import java.io.*; import java.io.IOException.*; public class StringToHexa{ public static void
help me to do it in jsp
help me to do it in jsp  if we click on a topic it should direct to another page in separate window i need to create a part of the web page which... to insert and update the topics via admin page. pls help me to do
what session.flush() do ?
what session.flush() do ?  Hi frineds , This is RajaSekharReddy can u Please answer these quesions 1.what session.flush() do ? 2.difference between load/get/criteria.these are all for retreving data or any difference
how to do this - JavaMail
how to do this  i have created three HTMl documents. i want to display three HTML documents combinely with in a single frame. can i save 3 HTMl combinely as single JSP.If combine how ? Plese send examples not only with HTML's
how to do gui
how to do gui  import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JOptionPane; public class ShippingCost { public static void... is RM" + num1); } } } how to do gui for this coding..tq   import
programes on do... while
programes on do... while   write a program to print reverse of a given digit write a program to check whether entered digit is palindrome or not write a program to check whether entered no. is Armstrong or not   1
cannot do the additional operator
cannot do the additional operator  i got problem with additional and multiplication operator...please anyone help me <html> <head> <title>Simple Calculator</title> <script language = "JavaScript
Using following-sibling in XPath
Using following-sibling in XPath   ... how one can use "following-sibling" axis in to the XPath expression. "following-sibling" has some other working rather than "
write a program in C to print following triangles on the screen
write a program in C to print following triangles on the screen  write a program in C to print following triangles on the screen
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
While and do-while
While and do-while      ... then we have to write down the following line... the following classes: class OuterClass {   ...   class InnerClass
i want print the following out put
i want print the following out put  Hello sir i want the following out put can u provide the program in c# o/p; HELLOLLEH HELLLEH HELEH HEH H
How do i do the coding for 'leaving a comment' in java
How do i do the coding for 'leaving a comment' in java  i am designing a webpage.In my webpage i want to add the option of adding a comment by the readers of the page.how do i do
What do I need to do to use a MSSQL-Server with Web-Harvester?
What do I need to do to use a MSSQL-Server with Web-Harvester?  What do I need to do to use a MSSQL-Server with Web-Harvester
how to get following answer in turbo c program
how to get following answer in turbo c program  input 123456789 output 1 2 3 4 5 6 7 8 9
Which of the following statements are true with respect to binary search
Which of the following statements are true with respect to binary search  Which of the following statements are true with respect to binary search? 1. The array need not be sorted for carrying out binary search 2. Binary search
How to access the following tag from xml to jsp
How to access the following tag from xml to jsp  How can i get the title where cat="1" and "My Title" from XML File?   Please visit the following link: http://www.roseindia.net/jsp/parsing-xml.shtml The above link
What do you mean by Deadlock?
What do you mean by Deadlock?  What do you mean by Deadlock
 

 

 

DMCA.com