URL in a string

Im trying to put a url in a string to print to an html file. Problem is the quotation marks. I tried using single quotation marks to mark the start and end of the string, except that didn't work. I was wondering what was the way around this?
aka String foo = '<a href="http://foo.bar/' + bar + '.ext">foobar</a>';now I know this doesn't work, but that's what im trying to pull off.

Gotta escape the double quotes:
        String bar = "bar";
        String foo = "<a href=\"http://foo.bar/" + bar + ".ext\">foobar</a>";%

Similar Messages

  • Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string co

    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete() _________________________________________________________________________________________ _____________________ stop(); var DepartVars:URLVariables = new URLVariables(); var DepartURL:URLRequest = new URLRequest("scripts/www.mywebsite.com/depart.php"); DepartURL.method = URLRequestMethod.POST; DepartURL.data = DepartVars; var DepartLoader:URLLoader = new URLLoader; DepartLoader.dataFormat = URLLoaderDataFormat.VARIABLES; DepartLoader.addEventListener(Event.COMPLETE, completeDepart); depart_btn.addEventListener(MouseEvent.CLICK, DepartUser); // Function to run when the Depart button is pressed function DepartUser (event:MouseEvent):void{             // Ready the variables here for sending to PHP           DepartVars.post_code = "Depart";         // Send the data to the php file           DepartLoader.load(DepartURL);         welcome_txt.text = "Processing request...Bon Voyage"; } // Close DepartUser function /////////////////////////////////////// // Function for when the PHP file talks back to flash function completedepart(event:Event):void{     if (event.target.data.replyMsg == "success") {             var refreshPage:URLRequest = new URLRequest("javascript:NewWindow=window.location.reload(); NewWindow.focus(); void(0);");             navigateToURL(refreshPage, "_self");         } // Close completeDepart function ////////////////////////////// // Code for the View res Button var viewRes:URLRequest = new URLRequest("view_res.php"); viewRES_btn.addEventListener(MouseEvent.CLICK, viewResClick); function viewResClick(event:MouseEvent):void {     navigateToURL(viewRes, "_self"); } ///////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // Code for the Edit Res profile Button var editRes:URLRequest = new URLRequest("edit_res.php"); editRES_btn.addEventListener(MouseEvent.CLICK, editResClick); function editResClick(event:MouseEvent):void {     navigateToURL(editRes, "_self"); } }

    this should be in the as3 forum.  but you need to return name/value pairs from your php file.

  • Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containin

    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete() _________________________________________________________________________________________ ____________ stop(); var DepartVars:URLVariables = new URLVariables(); var DepartURL:URLRequest = new URLRequest("scripts/www.mywebsite.com/depart.php"); DepartURL.method = URLRequestMethod.POST; DepartURL.data = DepartVars; var DepartLoader:URLLoader = new URLLoader; DepartLoader.dataFormat = URLLoaderDataFormat.VARIABLES; DepartLoader.addEventListener(Event.COMPLETE, completeDepart); depart_btn.addEventListener(MouseEvent.CLICK, DepartUser); // Function to run when the Depart button is pressed function DepartUser (event:MouseEvent):void{             // Ready the variables here for sending to PHP           DepartVars.post_code = "Depart";         // Send the data to the php file           DepartLoader.load(DepartURL);         welcome_txt.text = "Processing request...Bon Voyage"; } // Close DepartUser function /////////////////////////////////////// // Function for when the PHP file talks back to flash function completedepart(event:Event):void{     if (event.target.data.replyMsg == "success") {             var refreshPage:URLRequest = new URLRequest("javascript:NewWindow=window.location.reload(); NewWindow.focus(); void(0);");             navigateToURL(refreshPage, "_self");         } // Close completeDepart function ////////////////////////////// // Code for the View res Button var viewRes:URLRequest = new URLRequest("view_res.php"); viewRES_btn.addEventListener(MouseEvent.CLICK, viewResClick); function viewResClick(event:MouseEvent):void {     navigateToURL(viewRes, "_self"); } ///////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // Code for the Edit Res profile Button var editRes:URLRequest = new URLRequest("edit_res.php"); editRES_btn.addEventListener(MouseEvent.CLICK, editResClick); function editResClick(event:MouseEvent):void {     navigateToURL(editRes, "_self"); } }

    I have a similar problem
    whey I use .txt my code works, but when I change to .dat external file, it get error 1067
    my code:
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequest;
    var loader: URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, loading);
    loader.load(new URLRequest("rssnews.dat"));
    function loading(e: Event): void {
              news_1.text = trace(e.target.data.titulo);
              news_2.text = trace(e.target.data.texto);

  • Page not cached because "URL contains query string"

    I have used JDeveloper to produce a search/display page using ADF where the user enters search criteria and then presses a Search command button. The parameters are POSTed to the webserver, and I need to devise a cache rule to cache pages using the entered search criteria so that another seach for the same values can be served from the cache.
    I have created a rule that will cache GET, GET with Query String and POST.
    I have put .* in the POST body. When I do this, the first query page is retrieved from the origin server and cached and resulting queries with different search criteria are returned the data for that first search (ie. it's not taking into account the search parameters).
    If I switch off that rule and look at what's being received, I see the following:
    /158.234.27.10:8889/BM/faces/physical.jsp POST;;;event=&form1:selectOneChoice1=0&form1:selectOneChoice2=&form1:selectedDate=2004-08-10&form1:table1:rangeStart=0&form1:table2:rangeStart=0&form1:table3:rangeStart=0&form1:table4:rangeStart=0&form1:table5:rangeStart=0&form1:table6:rangeStart=0&oracle.adf.faces.FORM=form1&oracle.adf.faces.STATE_TOKEN=3&source=form1:commandButton1;;
    Now, there are 3 search parameter fields that need to be considered - the others should be ignored:
    form1:selectOneChoice1
    form1:selectOneChoice
    form1:selectedDate
    It's not clear to me where (and how - in what format) I specify parameters to ignore and parameters to consider. I have tried listing these 3 parameters in the URL parameters table for the Rule (I did not specify a value - should I have done?) but when I do this, the page is not cached and shows the reason for this is that "URL Contains Query String".
    Can someone explain how to specify important POST body parameters and unimportant POST body parameters?
    Thanks,
    Andy

    Hi,
    Please go through this:
    http://download-west.oracle.com/docs/cd/B14099_02/caching.1012/b14046/cache.htm#sthref1530
    Hope it helps you. I think you should be able to configure the intended rule in Web Cache.
    Regards,
    Priyanka GES

  • URL encode a string before redirecting it

    I want to URL encode a string before I sendRedirect it.
    What must I do? I have tried this but it did not work.
    response.sendRedirect(response.encodeRedirectURL("showAddAMember?century=" + country + "&stte=" + state + "&city=" + city + "&course=" + course + "&coursename=" + coursename + "&messagename=" + messagename + "&TFM=" + worker + "&admin_type=" + admin_type)); The URLEncoder.encode is deprecated so I can not use it or it is not wise to do so. What must I do to URL encode a string before redirecting it. I have written a simple method which temporarily takes care of this for me, but I want to use the accepted standard. Please somebody tell what I must do.

    I want to URL encode a string before I sendRedirect
    it.
    What must I do? I have tried this but it did not
    work.
    response.sendRedirect(response.encodeRedirectURL
    ("showAddAMember?century=" + country + "&stte=" +
    state + "&city=" + city + "&course=" + course +
    "&coursename=" + coursename + "&messagename=" +
    messagename + "&TFM=" + worker + "&admin_type=" +
    admin_type)); response.encodeRedirectURL() and .encodeURL() do not replace unsafe URL characters; I'm assuming that's what you want happening; they're meant to encode the session id in the URL for session tracking.
    Quote from http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html#encodeRedirectUrl(java.lang.String):
    Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
    For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
    Like mentioned above, use the URLEncoder.encode() ( with two params ): http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html#encode(java.lang.String,%20java.lang.String)

  • Transferrring parameter values from URL (by query strings)

    Hello,
    Is it possible to transfer username and password by a Url link with query strings? (http://help.sap.com/saphelp_nw04/helpdata/en/ce/3dd23a09313b37e10000000a11405a/content.htm )
    I tried the following URL pattern, but it didn't work..
    http://xxxxx.com:50000/irj/portal?sap-user=myuser&sap-password=123456
    Thanks for your help.

    you can try
    http://xxxxx.com:50000/irj/portal?j_user=myuser&j_password=123456
    Thanks
    puneet

  • 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

  • CSS Troubleshooting "advanced-balance url" based on string-range

    Hi together,
    a questions for troubleshooting "string range stickyness".
    I configured a content rule:
    content L5_HTTP_81
    vip address 192.168.1.1
    balance aca
    no persistent
    protocol tcp
    port 81
    url "/*"
    advanced-balance url
    add service service1 weight 1
    add service service2 weight 1
    string range 30 to 255
    string eos-char "_"
    string prefix "shopId="
    active
    service service1
    ip address 10.1.128.23
    keepalive maxfailure 2
    protocol tcp
    redundant-index 2102
    keepalive frequency 15
    keepalive retryperiod 10
    keepalive type http
    keepalive port 80
    keepalive method get
    keepalive uri "/admin/Ping.simple"
    string 148.49
    port 80
    active
    service service2
    ip address 10.1.128.22
    keepalive maxfailure 2
    protocol tcp
    redundant-index 2101
    keepalive type http
    keepalive method get
    keepalive frequency 15
    keepalive retryperiod 10
    keepalive port 80
    keepalive uri "/admin/Ping.simple"
    string 148.48
    port 80
    active
    1. I take a string from the 30rd to 255 character out of the URL starting at "/".
    2. Now I search for a string between "shop_Id=" and "_", on which the stickyness is based.
    3. string "148.49" is allocated to service1, string "148.48" is allocated to service2.
    Is there any possibillity to view or debug the handling, how the string is matched in the http request and on which service the request is forwarded ?
    thanks in advance
    sascha

    Here is the command reference. take a look at the available commands.
    http://www.cisco.com/univercd/cc/td/doc/product/webscale/css/css_710/cmdrefgd/index.htm

  • GetConnection(String URL) vs. (String URL, String user, String password)

    Hi,
    would have a question referring to the documention at http://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleDriver.html where the forms of getConnection are described.
    I would like to convert from using a signature that takes the URL, user name, and password as separate parameters to using a signature that takes the URL, user name, and password all as part of a URL parameter.
    While I was able to successfully connect to my database using the form getConnection(String URL, String, user, String password); I am not able to achieve the same when using getConnection(String URL).
    Here are the code snippets, maybe someone can point out the reason why the second approach is not working?
    approach 1 - working fine
    String driver = "oracle.jdbc.driver.OracleDriver";
    try {
              Class.forName(driver);
              } catch(java.lang.ClassNotFoundException e) {
              String connectionURL = "jdbc:oracle:thin:@localhost:1521:PMT";
              String pgUser = "\"James.Smith@000\"";
              String pgPwd = "\"js\"";
         try {
                   Connection conn = DriverManager.getConnection(connectionURL, pgUser, pgPwd);
    approach 2 - error: java.sql.SQLException: The Network Adapter could not establish the connection
    String driver = "oracle.jdbc.driver.OracleDriver";
    try {
              Class.forName(driver);
              } catch(java.lang.ClassNotFoundException e) {
    String connectionURL = "jdbc:oracle:thin:\"James.Smith@000\"/\"js\"@localhost:1521:PMT";
         try {
                   Connection conn = DriverManager.getConnection(connectionURL);
    Thanks a lot in advance
    Kind regards
    Thomas

    Let me get this clear.
    You want a login dialog.
    Some program calls the dialog and waits untile user respond
    once the user press ok or cancel it reutrn the users input to the caller.
    You can do this directly using JFrame
    but you can do it wil JDialog if you use it as aModal dialog.
    it will look like this
    class LogInDialog  extends JDialog implements ActionListener{
       String value;
       public LogInDialog(){
          setModel(true);
        // This is what you invoke
        public String loadDialog(){
            setVisible(true);
            return value;
        public void actionListener(..... e){
            if (e.getSource() == bCancel)
               value = null;
            else if (e.getSource() == bOk)
               value = //generate the string
            dispose();
    }

  • Storing OPC URL link as String

    Hello
    I am having trouble with reading OPC URL link in correct format form the System.ini file. (LabView 8.2)
    I am able to read the OPC URL link from System.ini file and save it as a string, but in the OPC URL link it contain some back slash and that is where the problem start.
    I have old EXE  file created in LabView, which read the same OPC URL and able to communicate. I cannot provide this EXE file because it is very big.
    Please take a look the System.ini file where OPC URL link are stored, and the OPC test.vi.
    I try to add some extra back slash to take care of escape sequence, but I could not communicate with OPC server.
    Please help me
    Thank you,
    Attachments:
    OPC test.vi ‏45 KB
    System.ini ‏1 KB

    Hello Guys
    Thank to Rolf, Ravens and GerdW
    As Rolf point out that read raw string flag on the Read key.vi takes care of  all escape sequence problem. Also do the same thing when you use the Write Key.vi. So if the Value type is String then this flag comes up, but if not careful we can easily miss that.
    Here is the some more info.
    read raw string? Specifies whether the string was written without escaping unprintable and backslash (\) characters. If FALSE (default), the VI replaces any unprintable characters in the string, such as <ESC>, with a backslash and two Hex characters (\xx). If TRUE, the VI does not convert the unprintable characters in the string.
    write raw string? specifies whether to write the string without escaping unprintable and backslash (\) characters. If FALSE (default), the VI converts any backslashes (\) to double backslashes (\\) and replaces any remaining unprintable characters in the string, such as <ESC>, with a backslash and two Hex characters (\xx). If TRUE, the VI does not convert the unprintable characters in the string.
    I think this is very important point to keep in mind.
    Thank you

  • How to get URL type from String.

    Hi,
    Is there any way to convert a String or String to int to URL type? For example, I getting value form a JTextArea. This value will be a int ( A combination of number only) so I am converting the String the int and then can it be converted into URL???
    Thanks

    merit wrote:
    I tried reading it but I dont understand the syntax. Can you please show me how to do this?
    public uRLReader(String uRL)throws MalformedURLException{
                   URL newURL = new URL(uRL);
    retrun (newURL);
              }will this code convert the String to URL type?
    Thank you.What don't you understand? If you don't know how to use the API docs to use a class, then you need to start from the very beginning of a Java tutorial.
    Also, you have what looks like a constructor, but it's returning a value. C'tors don't return values at all, and the value you're trying to return is a URL, which means you'd have to declare this as a method that returns URL.
    You seem to be struggling with basic, fundamental concepts. I recommend you get a better handle on those before trying to do anything with URLs.
    [http://java.sun.com/docs/books/tutorial/]

  • Report Builder Action Go to URL Duplicates Query String

    I'm trying to create a link back to SharePoint list item's dispform from a text box action within a report builder report. The report's datasource/set is the same SharePoint list I'm trying to link back to.  I'm using the following
    "Select URL" expression.
    ="http://site/subsite/DispForm.aspx?ID=" & cstr(Fields!ID.Value)
    The result when clicked is http://site/subsite/DispForm.aspx?ID=7&ID=7 (it should be http://site/subsite/DispForm.aspx?ID=7)
    I also tried creating the link by changing the markup to HTML and stringing the HTML in the field's value by this expression.
    ="<a href='http://site/subsite/DispForm.aspx?ID=" & cstr(Fields!ID.Value) & "'>" & cstr(Fields!AccountID.Value)& " | " &cstr(Fields!HAN.Value) & "</a>"
    I get the same result when clicked, http://site/subsite/DispForm.aspx?ID=7&ID=7 (it should be http://site/subsite/DispForm.aspx?ID=7)
    I'm really not sure what's going on.  Has anyone experienced this behavior before?
    Thanks in advance!

    Hi kofg,
    From your description, I tried to reproduce this issue on my test environment. However, the drillthrough function is work normal in my report. In your case, please post more information about the versions of the Reporting Services and SharePoint.
    You can try to use the following expressions for the drillthrough function:
    ="http://site/subsite/DispForm.aspx?ID=" & CInt(Fields!ID.Value)
    Or
    ="http://site/subsite/DispForm.aspx?ID=" & Fields!ID.Value
    Regards,
    Bin Long
    TechNet Subscriber Support
    If you are TechNet Subscription user and have
    any feedback on our support quality, please send your feedback here.
    Bin Long
    TechNet Community Support

  • Store current page url into a string

    What method do i use to store the url of the page that the applet is being viewed?
    The reason i need this is because my applet would produce a different output if the url was http://dimg.biz/1.php as opposed to http://dimg.biz/2.php.

    getDocumentBase(). It's a method of Applet.
    It's right there in the API docs.

  • Code to parse string to retrieve URLs

    Hi all,
    I need a code to parse a string to get all URLs in that string. Pls help me.
    Thank you

    This is basic string coding. Read http://java.sun.com/docs/books/tutorial/java/data/strings.html

  • Extract URL from a href string

    Greetings,
    I am trying to solve a problem (in a specific way) that will lead to the solution for another problem (which is similar).
    I am trying to extract a URL from an HTML <a> tag like this:
    <a href="www.someurl.com">Go to www.someurl.com</a>Can anyone help with the best solution? I've tried it using String.split() and StringTokenizer (which might work for this example), but, for my real problem, they seem quite inadequate. I'm guessing the solution involves some regex but I don't know where to look (and am quite unfamiliar with regex to know how).
    Thank you in advance.

    Actually, I am trying to break down many sections of the URL.
    The URL I am trying to breakdown has a lot of data that I need.
    I guess a better example would be:
    <a href="www.someurl.com" id="url-id-43612">Link Text - data here</a>In my program, I need to grab three things: the href URL, the id, and "Link Text - data here."
    Here is an SSCCE of how I am currently dealing with this:
    import java.util.StringTokenizer;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Ryan
    public class htmlparser {
        public static void main(String[] args) {
            String str = "<a href=\"www.someurl.com\" id=\"url-id-43612\">Link Text - data here</a>";
            str = str.replaceAll("<a href=\"", "\n")
                .replaceAll("\" id=\"url-id-", "\n")
                .replaceAll("\">", "\n")
                .replaceAll("</a>", "\n");
            StringTokenizer tokenizer = new StringTokenizer(str, "\n");
            String url = tokenizer.nextToken();
            String id = tokenizer.nextToken();
            String text = tokenizer.nextToken();
            System.out.println(url);
            System.out.println(id);
            System.out.println(text);
    }But I am looking for a more elegant solution to the problem, is there one?

Maybe you are looking for

  • PM 7.0 to InDesign

    Can I upgrade from PM 7.0 to InDesign or do I have to purchase the complete suite?

  • Why should we calculate cumulative balance as per posting period?

    Hi, I dont know whether we can pose this type of questions here or not. Why should we calculate cumulative balance as per the posting period? How is it going to work? Hope I will get an answer. Thank you

  • Birthdays did not appear in iCal after update from Contacts

    I thought iCal is supposed to automatically import birthdays from "contacts"? I went to contacts and selected "birthdays" to be displayed. Then typed in the bday info, saved the cards, and went to look at my ical. nothing happend. did i miss some vit

  • Internal and External DVD players keep ejecting DVDs

    i have a G4 500mhz AGP mac (upgraded to a 1.6ghz processor via a NewerTech card) with an internal CD/DVD player (not burner) and i have an external LaCie CD/DVD burner (the LaCie CD/DVD burner is only about 4 weeks old and i've burned maybe 8 to 10 D

  • [svn:fx-trunk] 12817: TextField measurement bug fix

    Revision: 12817 Revision: 12817 Author:   [email protected] Date:     2009-12-10 16:19:53 -0800 (Thu, 10 Dec 2009) Log Message: TextField measurement bug fix SDK-24560 - Scaling errors in UIFTETextField and UITextField Fixed the measuredHeight and me