String Manipulation in JSP

Gidday All,
I am converting an application from PHP to JSP
in PHP I am able to explode a strings parts into an array.
For example
my string = "1.21.32.45.232";
I want jsp to return an array containing the parts of this string separated by dots into an array.
Any help appreciated.
Thank You
Colin

Thanks everyone for your help,
I knocked this up but don't get any output?
Any help appreciated.
Thank You
Colin
<html>
<head>
</head>
<%@ page language="java" import="java.util.StringTokenizer" %>
<body>
<%
StringTokenizer st = new StringTokenizer("123.21.56.23", ".");
while ( st.hasMoreTokens() ){
System.out.println( st.nextToken() );
%>
</body>
</html>

Similar Messages

  • String manipulation in JSTL

    Hello All
    I'm a just a beginner and I'm need to write a web page that is totally based on JSTL. I found out that the standard java tab lib in JSTL doesnt really support string manipulation or regular expression like in perl.
    As such, I would like to know what are the different options (like adding servlets/javabeans/etc) can i add to my JSTL page so that i can perform complex string manipulation to a data entered by the user in the text box?
    Some of the operations that I wish to carry out on the data are:
    1. check if data contains certain characters, strings
    2. joining and spliting strings
    3. find length of the string
    4. find the position of certain character in a string
    5. check if string match certain pattern.
    and many more.
    Would greatly appreciate if you guys can help to provide some light.
    Regards
    Beginner....

    You might find MicroNova YUZU JSP tag library (http://sourceforge.net/projects/micronova-yuzu) useful, especially if you need to support both JSP 1.2 and 2.0. Hope this helps.

  • String Manipulation in BI Publisher Report Paramater

    Hi,
    My Problem is that I am not able to do string manipulation on BI Publisher report Prameters.
    Actually I want to Show Deptno-Dname in Menu(LOV).and when I select Certain combination like '10-Accounting',and while passing the parameter:Dept I wanted to Cut the department no(10) using string manipulation functions provided by oracle in Data Model(Query) in where clause like (where deptno=to_number(substr(:Dept,1,2)).
    This query is working fine in other application like TOAD,But not giving results in BI Publisher Report.
    It's also not giving any error while saving or running the report.
    Please suggest any solution.

    even I tried the following query in data model..
    select DISTINCT EMP.EMPNO as EMPNO,
    EMP.ENAME as ENAME,
    EMP.JOB as JOB,
    DEPT.LOC as LOC
    from SCOTT.DEPT DEPT,
    SCOTT.EMP EMP
    where emp.DEPTNO=DEPT.deptno
    and DEPT.deptno=nvl(to_number(substr(:department,1,2)),DEPT.deptno)
    But the Parameter which I want to pass say Department('10-Accounting'),
    Still it is showing employees from all departments.

  • % in a String breaks Oracle JSP / JDeveloper parsing

    Hi.
    I'm running JDeveloper 9.0.3 Production
    I found that entering %> in a String in a JSP-page breaks the page.
    To verify that I created a new JSP-page by using the New->JavaServer Pages->JSP Page and adding the code snippet
    <% String s = "AA%>BB"; %>
    to the page.
    The syntax-coloring scheme in JDeveloper shows that it assumes that the string s is terminated after AA when it encounters the %> charaters.
    This behaviour shows in JDeveloper 9.0.2, 9.0.3 Pre and the brand new 9.0.3 production.
    This means that this code can't execute on my oc4j.
    It works perfectly on Tomcat 4.0 though
    Any ideas anybody?
    Complete JSP-page supplied below
    /Jan-Erik
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html><head>
    <title>Hello World</title>
    </head>
    <body>
    <% String s = "AA%>BB"; %>
    </body>
    </html>

    Hi,
    Try the Following. This works in OC4J(latest version).
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html><head>
    <title>Hello World</title>
    </head>
    <body>
    <% String s = "AA%\>BB"; %>
    </body>
    </html>
    \ is the escape character.
    Hope this helps,
    Rajat,
    OTN Team @IDC

  • How would I do a http post of the below listed XML string within a JSP?

    Hi,
    How would I do a http post of the below listed XML string within a JSP?
    <DoService xmlns="http://www.gdinrw.org/wss" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WSS" version="1.0">
    <ServiceRequest DCP="HTTP_POST" mimeType="text/xml" encoding="UTF-8"><![CDATA[REQUEST=GetCapabilities&SERVICE=WMS]]></ServiceRequest>
    <AuthMethod>urn:opengeospatial:authNMethod:OWS:1.0:password</AuthMethod>
    <Credentials>guest,guest</Credentials>
    <FacadeUrl>https://bern:8443/wss_umn_wms/WSS</FacadeUrl>
    </DoService>
    Thanks,
    John

    Yes,
    I need to set up data as POST format before I POST it.
    To be more specific I know how to post within a JSP if an xml element is like:
    <AuthMethod>urn:opengeospatial:authNMethod:OWS:1.0:password</AuthMethod>
    where the field is AuthMethod and the value is urn:opengeospatial:authNMethod:OWS:1.0:password
    but what I am not sure of is when the field has values embedded within it like:
    <ServiceRequest DCP="HTTP_POST" mimeType="text/xml" encoding="UTF-8"><![CDATA[REQUEST=GetCapabilities&SERVICE=WMS]]></ServiceRequest>:
    It has a field of ServiceRequest and a value of ![CDATA[REQUEST=GetCapabilities&SERVICE=WMS]]
    but it also other value embedded with ServiceRequest like mimeType="text/xml" .
    Thanks,
    John

  • The best  way of carrying the search string across different jsp pages?

    I heard about transfer object. What about carrying object with session for different pages.
    Please suggest me the best approach to
    carry the search string across different jsp pages?
    thanks
    vijendra

    I doubt its possible even with a fancy HTML widget, although the last iBA update now allows links to other books.

  • String manipulation: php to jsp

    Im converting a menu generation program from PHP to JSP.
    Every page in my site has been allocated a page Id.
    A pages pageId determines how the primary navigation of the page displays.
    My Question
    I need to determine the sub Menu parent id To do this in php I can just take the int value of the pageId string to get 2
    <?php
    $pageId = "2.1.3.4";
    $subMenuParentId = intval($pageId);
    ?>
    how can I do this in JSP ? Is there a better solution.
    <%
    String pageId = "2.1.3.4";
    %>

    You might find this test program novel...
    import java.text.*;
    public class msgfmttest
        public static void main(String[] args)
         MessageFormat msgfmt = new MessageFormat("{0,number,integer}.{1,number,integer}.{2,number,integer}.{3,number,integer}");
         String pageId = "2.1.3.4";
         try {
             Object[] levels = msgfmt.parse( pageId );
             int level1 = ( (Long)levels[0] ).intValue();
             int level2 = ( (Long)levels[1] ).intValue();
             int level3 = ( (Long)levels[2] ).intValue();
             int level4 = ( (Long)levels[3] ).intValue();
             System.out.println("level 1: " +  level1);
             System.out.println("level 2: " +  level2);
             System.out.println("level 3: " +  level3);
             System.out.println("level 4: " +  level4);
         catch(ParseException exc) {
             System.err.println("pageId is invalid");
    }

  • Display CDATA in a String XML into JSP

    hi ,
    I have the following requirement..
    String xmlString="<?xml version='1.0' standalone='yes'?><Errors><PROCESSID>GRANT00100478</PROCESSID>
    <formname>Error</formname><ProcessingError>0<TYPE>XMLWELLFORMATERROR</TYPE>
    <LEVEL>FATAL</LEVEL**>
    <INFO><![CDATA[ DefaultValidationHandler found 2 problems: 2 Errors: 1: (line 2 column 11168) cvc-minLength-valid: Value 'CA123456'
    with length = '8' is not facet-valid with respect to minLength '9' for type 'DUNSIDDataType'. 2: (line 2 column 11168) cvc-type.3.1.3:
    The value 'CA123456' of element 'globLib:DUNSID' is not valid. The document is NOT valid!]]></INFO>**<ERRORTYPEACTION />
    <ERRORTYPEDESCRIPTION><![CDATA[ XML is not Well-Formed.]]></ERRORTYPEDESCRIPTION><ERRORTYPELONGDESCRIPTION>
    <![CDATA[]]></ERRORTYPELONGDESCRIPTION></ProcessingError></Errors>";
    My requirement is i need to display the <INFO> tag value in my JSP ..
    Please help me in this matter..Please send me sample code...if possible..
    thanks in advance...
    regards,
    SUBHASH.
    Edited by: subbuhunk on Apr 3, 2008 3:37 AM
    Edited by: subbuhunk on Apr 3, 2008 3:38 AM

    I would use the JSTL <x:parse> element to parse the string, followed by the <x:out> element with a suitable XPath expression to select that node.

  • How to Display string array in jsp page using netui-data:repeater tag ??

    hi,
    I am trying to display a string array in a table using the netui-data:repeater tag.
    I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
    Can any one tell me how to print the array in a table of 3rows & 5 columns.
    Here is the code on which I am crrently working on.
    <netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
    <netui-data:repeaterHeader>
    <table cellpadding="4" border="1" class="tablebody">
    </netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <tr>
    <td><netui:label value="{container.item}" >
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    </tr>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter>
    </table>
    </netui-data:repeaterFooter>
    </netui-data:repeater>

    weblogic.developer.interest.workshop
    Mansoor Naseem wrote:
    I would like to know where the pageflow newsgroup is.
    These are all the groups in weblogic.developer.interest:
    weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
    weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
    weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
    weblogic.developer.interest.commerce weblogic.developer.interest.personalization
    weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
    weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
    weblogic.developer.interest.jdbc weblogic.developer.interest.security
    weblogic.developer.interest.jms weblogic.developer.interest.servlet
    weblogic.developer.interest.jndi weblogic.developer.interest.tools
    weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
    MN

  • How do i pass a url with query string using the jsp:forward tag

    This snippet of code gives a 403 error
    <jsp:forward page="testpage.jsp?test=1" />
    How do i rectify it?

    Well better way to go about for the job is to use
    setAttribute("name","value");method in the first page
    and then in next page use method
    String s=getAttribute("name");to retreive the value.
    Url rewritting or using Query String has some disadvantages ,which are handled by above mentioned approach.
    Ashish

  • Problem in showing value of a string object of jsp to on page

    hello there
    i have a problem that i m fatching a value from a JavaBean in my jsp page now i want to print that value in my jsp page but i is createing problem
    my probelm is that the value which i have been fatching from my javabean contain code like
    #include<stdio.h>
    #include<conio.h>
    void main
    int a=10;
    printf("%d",a);
    getch();
    i m getting this code in a variable in a String object myCode
    and when i m displaying this using
    <%=myCode%>
    it is giving output as follows
    #include<stdio.h> #include<conio.h> void main { int a=10; printf("%d",a);
    getch();}
    can you tell me why it is creating a problem
    plz help me
    thanks in advance
    pawan gupta

    HTML formats in its own special way. It ignores spaces/newlines.
    Try using <pre> tags to tell the browser "this is pre-formatted text. Don't screw around with it"
    ie
    <pre><%= myCode %></pre>
    Cheers,
    evnafets

  • Query string error in JSP

    Hi. I originally thought my problem was a javaScript problem but now realize it is a JSP problem:
    I have a JSP calling another JSP (which is opened in a smaller window with javaScript) and it uses a query string for values. One of these variables in the string is a note the user enters and can contain anything. Problem is when they enter text with the '&' symbol, I'm getting a Null Pointer Execption as the receiving JSP interprets it as part of the query string.
    How can I 'hide' these characters so the receiving JSP page doesn't try to process it?
    Thanks in advance,
    Mike

    hi,
    you could detect the string before you sent the string, check for the & symbol and replace it with something else, such as the html equivalent and then append it to the url and send it, on the other end read it and replace the symbol with the & to get it back without confusing the code. you would run into the same problems if the user enter = or possibly ? into the string, so try fixing it with a search and replace method.

  • Query string access in jsp

    I want to access the query strings from this URL. http://localhost:8080/napstersBank/imageone.jsp?39,23
    I tried javascript method window.location.search.substring(1); but i want to implement it in JSP due to security reasons.
    How to extract the query string from the above URL.
    Thank you in Advance

    I am not sure of what exactly the question is.
    Are you asking about how to access variables in JSP ? Or how to pass a parameter from an HTML page to a SWF ?
    Here:
               'meetingModule.html?roomURL=<%= roomURL  %>&authToken=<%= token %>',
    you are simply passing variable to the HTML page. From there you need to use javascript to parse the query string and pass the values to your SWF.
    If you look at the ExternalAuthentication examples they all do something similar.

  • String Tokenizer in JSP

    What is the best way to write a string tokenizer is a JSP page??
    I am passing a vector to the JSP page which is being outputted on to the page and now I want to edit the contents of the vector. I need to tokenize the vector into a series of strings but I am making a hash of it so far.
    Is there a better way to do this?

    I'm not sure what your exact question is. StringTokenizer works with String classes not Vectors. Do you want to change the data in the Vector and leave the Vector in tact, or do you want to retrieve the data from the Vector and do something with it?
    You can retrive the contents of the Vector into an Object array, or you can enumerate through the elements, or you can use the get method itself. It depends on what you need to do.

  • Pls help Session manipulation in Jsp

    Hi,
    In JSP, I wanna check whether user has logged in, but it doesn't work, could you pls help?
    I guess the reason is I didn't initiate session attribute of userid. If it is true, could u pls tell me how to do that?
    or, how to know the attribute not set yet?
    TIA
    Wolf
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <%
         String jsp_userid=null;
         jsp_userid=session.getAttribute("userid").toString();
         if (jsp_userid==null) {
                   response.sendRedirect("/loginfailure.jsp");
         } %>

    I guess the reason is I didn't initiate session
    attribute of userid. If it is true, could u pls tell
    me how to do that?
    or, how to know the attribute not set yet?Are you sure you are putting an attribute by name "userid" in the session soon after/during login?Otherwise you will get null on doing a getAttribute.
    Do something like session.setAttribute("userid",sUserId); during login.
    jsp_userid=session.getAttribute("userid").toString();And don't do the above. your session.getAttribute("userid") may well return null
    Make it something like
    jsp_userid=(String)session.getAttribute("userid");
    if(jsp_userid==null)

Maybe you are looking for

  • Zen V Plus - how do i delete (podcasts and mus

    Hallo, am newbie to MP3 - bought Zen V Plus v ..0e 4GIG - very happy, small enough to fit into my bra. HOWEVER, disappointed with the manual - all of 6 pages of rubbish and have spent hours trundling through 'Help' without much success. Problem == po

  • Windows 7 Prof. decryption on an external hard drive (WD My Passport) DOES NOT WORK

    I cannot decrypt files and subfolders of a top folder on a WD My Passport hard drive using the "advanced attributes" of folder "properties". (The "advanced attributes" of folder "properties" works on the internal hard drive.) I can decrypt a file ind

  • Is a and has relation

    About the "IS-A" and "Has-A" relationship. 1.Well ,i am a new-bees for Java.Refer to the question and answer from Mock exam 3 below , i had refer to it so many times but still did not get it.If possible ,please provide a minimum syntax base on the qu

  • Is there any method to export the data from oracle 10g in any format !!!!!

    is there any methods to export the data from oracle 10g in the format of excel or csc or txt or anyother. i already downloaded the sql developer tool but it only exports the data of upto one lakh rows ,but i have two tables of more than 3 lakh and 10

  • Best practice for constructing an editable, saveable form?

    We're entirely new to LiveCycle here, but we're looking to create a document for one purpose: To allow a user to edit their details into the form, email/send ourselves the completed form, and (for legal reasons), leave a fully saved copy of the form