Get "#"  from URL into servlet

Hi
I am writing a servlet which can check that the requested URL is having "#" or not.?
Let's say my URL is like, http://abc.com/#/efg/hij.jsp
As it is having "#' sign in the URL string, So I need to check the existence of "#" in requested URL.
My problem is when I write ..
StringBuffer url = request.getRequestURL();
String requestedURL = url.toString();
requestedURL only provides me the string before "#" i.e. http://abc.com/
I need to check if it has "#" or not with whole URL string.
Is there any way to check that into servlet.?

The # sign is a client side sign telling it to go to a bookmark with the name following the # sign. The # sign is not part of the requested URL, so you can't get it on the server side.
If you are generating URLs with the # sign and trying to make it do something you should re-think the design since the # sign is reserved for client side use.
Alternatively you could try to pass any URL that does have the # sign through java.net.URLEncoded.encode(theURL, "UTF-8") to see if you can then get it back on the server.

Similar Messages

  • Part 2: Load Image from URL into Dynamic Text Box - goodinson.snapshot

    I have a flash file where a user can add an image url into a Dynamic Text Box (image_in.text) and the image will now appear in the flash file.
    I am using goodinson.snapshot as featured in this article: Saving Flash graphics as image files at runtime | Adobe Developer Connection
    This application works fine (graphic is generated and downloaded) only if a user chooses an included graphic in the flash file (loaded externally) or if I declare a url inside the flash file for the load image variable (var image_url:String = "http://website.com/image.jpg";).
    However, if a user enters an image url into the Dynamic Text Box (image_in.text), which the flash does successfully load, the download image function no longer works!
    Is this a security bug in flash itself? Or am I missing a code tweak somewhere? 
    If an FLA that does this already exists somewhere, let me know.
    Thanks in advance for your help!

    Thanks for your response!
    The image urls are on the same domain as where the swf is.
    I don't understand how declaring the variable as the url is different from declaring it from the value of a dynamic text box... it's the same url, but only one method works, shouldn't they both work?
    var image_url:String = "http://website.com/image.jpg"; works..
    var image_url:String = image_in.text; does not work, even though the value for image_in.text is identical to the one in the example above.
    Since they are all on the same domain, this should work, right?
    Thanks again.

  • Dynamic Image (.gif) from URL into adobe Form by SFP

    Hi all
    I post the comment of Shamila because I have the same problem
    I need to place an image in the Adobe form based on the url.
    I have written the following formcalc script in the image field form ready action
    ImageField1.value.image.href = "http://www.adobe.com/imageshome/pdfgift_home.gif"
    But when i view the form , the image field is empty, and when i click on the blank space of the image field, a popup appears to select the image............
    How can i show the image from url in the form..........
    Regards,

    Hello,
    have you checked these basics documents?
    When you need to send a picture into the offline form: another image question - using Regular ABAP not web dynpro and Display a logo dynamically in adobe form
    Where to start with scripting: http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Also try: Re: Dynamic R/3 Image URL in Adoeb Form
    regards, Otto

  • Get base URL during servlet init()

    How can I obtain a Application Server's base URL during a servlet's init(), i.e. not using HttpServletRequest later
    e.g. for servlet test accessible at http://localhost:8080/contextroot/test
    base URL = "http://localhost:8080/contextroot/"
    After some testing the closest I've got is "jndi:/server/contextroot/". Can I get a HTTP URL from this?
    public void init(ServletConfig config) throws ServletException {
    super.init();
    try {
    path = config.getServletContext().getResource("/");
    } catch (Exception e) {
    System.out.println("e: " + e.toString());
    Any ideas appreciated. Thanks in advance.
    Java EE 5

    All what you have in the init() method is the ServletConfig. Have you checked its javadoc to see what it all offers?
    [http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletConfig.html]. Hint: check the other getters of ServletContext.

  • Getting env variables into servlet

    I am making a call to a servlet http://3.70.201.210/servlets/basic?cmd=Attach
    Apparently, the servlet is not getting some of the environment variables it needs to make use of due to which it fails to load and the browser times out.
    In httpd.conf, I use
    PassEnv TARGET_ROOT
    PassEnv PRODUCT
    but they dont seem to get passed
    It was working before. All I did was upgrade Apache from 1.3.28 to 1.3.29. jserv version has been the same in both versions.
    Any pointers.
    Thanks in advance for any help or suggestions.

    Found it .. adding
    wrapper.env=var=value
    in jserv.properties fixed it !

  • Reading a pdf file from URL into Byte array/ByteBuffer in an applet.

    I'm trying to figure out why this particular snippet of code isn't working for me. I've got an applet which is supposed to read a .pdf and display it with a pdf-renderer library, but for some reason when I read in the .pdf files which sit on my server, they end up as being corrupt. I've tested it by writing the files back out again.
    I've tried viewing the applet in both IE and Firefox and the corrupt files occur. Funny thing is, when I trying viewing the applet in Safari (for Windows), the file is actually fine! I understand the JVM might be different, but I am still lost. I've compiled in Java 1.5. JVMs are 1.6. The snippet which reads the file is below.
    public static ByteBuffer getAsByteArray(URL url) throws IOException {
            ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
            URLConnection connection = url.openConnection();
            int contentLength = connection.getContentLength();
            InputStream in = url.openStream();
            byte[] buf = new byte[512];
            int len;
            while (true) {
                len = in.read(buf);
                if (len == -1) {
                    break;
                tmpOut.write(buf, 0, len);
            tmpOut.close();
            ByteBuffer bb = ByteBuffer.wrap(tmpOut.toByteArray(), 0,
                                            tmpOut.size());
            //Lines below used to test if file is corrupt
            //FileOutputStream fos = new FileOutputStream("C:\\abc.pdf");
            //fos.write(tmpOut.toByteArray());
            return bb;
    }I must be missing something, and I've been banging my head trying to figure it out. Any help is greatly appreciated. Thanks.

    Keshav.. wrote:
    I too was going through the same problem but I found for some pdfs it worked fine.I didnt get ur solution.Please explain bcoz it may work for every pdfThis thread is over 3 years old and dead. Please open a new thread which provides details of the problem you are having. Link to this thread if you think it is necessary.
    I shall lock this thread.

  • Get flv url from swf

    How can you find the url location of an flv file.... for
    example how could i find the flv of a youttube video... this must
    be possible as their are sites that enable you to download the flv.
    kind regards J.... p.s. merry christmas.

    So there is no direct way to get the url into flash?...
    The thing is that I`m making some multi-languaged banners for another programmer. The url`s used in his site have a ln parameter from which I could get the language.
    So then... I could call a JavaScript function with ExternalInterface from flash and get the url then move on with my bussiness form there, right? I dont`t know Java script though... You think you could give me the code?... Thanks in advance!

  • How to get full URL in java?

    Hi,
    I am working in a spring & hibernate project. For the AJAX request to bookmark, I used RSH (Really Simple Framework) framework. So, my URL changes for the AJAX request as
    http://localhost:8080/courses#/medicaltranscription/cardiology
    If I bookmark this and open in a new window, I can’t get full URL in Servlet. If I use methods in Servlet, it gets only, upto http://localhost:8080/courses. I can’t get the whole URL. Please, help me to find a solution.
    Thank you

    The hash part is entirely client side. You cannot get it on the server side. You need to pass it as request parameter or as part of real URL.

  • Embedding images into servlets

    I have a problem with showing two png files (or jpg files) in the same servlet. I probably thought that I cannot.
    So I thought I will do the following: Load a html file as output to the user and include references to two servlets, each displaying one png file. Do I have to use .shtml file to do that? And how do I send the HTTPRequestInfo I get from my original servlet to these 2 servlets?
    thanks
    Mahesh :)

    How do I use the img tag?? I was reading my .png file and creating a ByteArray of data (pixel info) and output that through ServletOutputstream. I am using response.setContentType("image/png"). If I did this with 2 image files, only the first one wud show up.
    please advise.
    thanks
    mahesh

  • Web.xml - can't get the url from xml file..

    Hi all,
    Im a beginner @ jsp =)
    My question is as follow..I cant get base from the web.xml file.
    This is a shorten version of my web.xml..
    <web-app>
         <welcome-file-list>
    <welcome-file>Default.jsp</welcome-file>
    </welcome-file-list>
         <!-- Define the controller servlet -->
         <servlet>
              <servlet-name>ControllerServlet</servlet-name>
              <servlet-class>ControllerServlet</servlet-class>
              <!-- Define initial parameters that will be loaded into
              the ServletContext object in the controller servlet -->
         <init-param>
                   <param-name>base</param-name>
                   <param-value>http://localhost:8080/burnaby/ControllerServlet</param-value>
              </init-param>
    </servlet>
         <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/ControllerServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    And my jsp file:
    <%
         String base = (String) application.getAttribute("base");
         String imageUrl = (String) application.getAttribute("imageUrl");
    %>
    <table width="740" cellpading="0" height="75" cellspacing="0" border="0">
         <tr>
              <td align="left" bgcolor="#F6F6F6">
                   <font face="Verdana" size="3">Sky's E-mall!</font>
              </td>
              <td align="right" bgcolor="#F6F6F6">
                   <a href="<%=base%>?action=displayShoppingCart"><img border="0" src="<%=(imageUrl + "cart.gif" )%>"></a>
                   ���
              </td>
         </tr>
    </table>
    I have written it of a book im reading and i cant get it to work. Base and imageUrl always become null.
    thank you
    /Robert

    I'm a little new to JSPs and servlets too, but I'll give this one a shot. I think since your variables like 'base' are servlet initial parameters, they don't get initialized until you actually call the servlet ( I'm not 100% on this, though). Try calling the servlet and having it forward the response back to your original JSP and see if you get values then.

  • How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP server

    In 9iAS 9.0.2 Oracle HTTP Server (OHS) is pre-configured to assign requests to the Home OC4J instance via the URL-prefix "/j2ee"/
    For example, the TEST servlet under OC4J would be passed through OHS using:
    http://urmachine:urApachePort/j2ee/TEST
    whereas in the standlone OC4J version, this URL works:
    http://urmachine:urOC4JPort/TEST
    How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP Server?

    It is getting the url prefix from mod_oc4j.conf
    under /ora9ias/Apache/Apache/conf
    You can read more on this at
    http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/web.902/a92173/confmods.htm#1008977
    -Prasad

  • Is it possible to dwnload a file from web with given URL into our local sap

    Hi every Body!
    Is it possible to download a file from web with given URL into local PC with abap.
    thanks
    vikram.c

    hi
    good
    go through this link, i hope this ll help you solve your problem
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f5d3c40a-0801-0010-55b7-9e3b01745a40
    thanks
    mrutyun^

  • Get parameter from URL in Java code

    Hello everyone,
    I've got strange problem. I have one JSF page with two controls:
    - InputText
    - Button
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <af:document title="view12.jsf" id="d1">
    <af:messages id="m1"/>
    <af:form id="f1">
    <af:inputText label="Label 1" id="it98" value="#{param.test}" editable="always"/>
    <af:commandButton actionListener="#{bindings.przekierowanie.execute}" text="przekierowanie"
    disabled="#{!bindings.przekierowanie.enabled}" id="cb1"/>
    </af:form>
    </af:document>
    </f:view>
    And I want to initialize the InputText with parameter from URL (param name is test - value="#{param.test}"). In JSF page everything is fine. But after clicking button I have to read the value from InputText in Java Code, so I have URL:
    http://127.0.0.1:7101/Application6-ViewController-context-root/faces/view12.jsf?test=asd
    and my Java code which is executed after clicking button is:
    public String przekierowanie() {
    Map <String,String> map=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    String tttValue=map.get("test");
    System.err.println("test:" + tttValue);
         return null;
    but this doesn't work... Everytime I get null when I click the button. Could you tell me why and How to obtain this value, from InputTex in my java function?

    Hi,
    If you have a parameter in URL named as "product", you can get its value like:
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpServletRequest;
    FacesContext facesContext = FacesContext.getCurrentInstance();
    HttpServletRequest httpRequest =
    (HttpServletRequest)facesContext.getExternalContext().getRequest();
    String product = httpRequest.getParameter("product");

  • I'm getting a message "404 (page not found error)" I think I entered an incorrect URL into my browser's address bar. How do I fix that?

    I was trying to post a comment on a support group site. I was asked what web address I was using, or something along those lines. In hindsight, I stupidly typed a '?' and pressed send. Now, when I try to access that site I get the message "404 (page not found error)
    If you're the site owner, one of two things happened:
    1. 1) You entered an incorrect URL into your browser's address bar, or
    2. 2) You haven't uploaded content."
    How can I fix this.

    I spoke with a Dell technician about this problem. He tried to access the site in question from his computer, i.e. separate from my computer, and he also got the same "404 (page not found error)". He said the problem lies with the site itself, not my computer, and that I should notify the site. Problem is I can't notify the site if I can't access it.

  • I update my IPhone4 to IOS6 from IOS4.3.3. My all songs are missing in the Iphone4. How to get those songs into my Iphone from ITunes. Even after sync also not coming to IPhone.

    I update my IPhone4 to IOS6 from IOS4.3.3. My all songs are missing in the Iphone4. How to get those songs into my Iphone from ITunes. Even after sync also not coming to IPhone.

    The iphone is not  storage/backup device.
    The sync is one way - computer to iphone.
    The only exception is itunes purchases.  File>Devices>Transfer Purchases
    You should copy everything from your old computer, or your backup copy of your old computer, to your new one.

Maybe you are looking for

  • Cannot connect to database using SQL*Plus

    Hi, I have Oracle 10g XE installed in my labtop and I cannot connect using SQL*Plus. I can connect using the broser User Interface though, which I was able to do after doing the following procedure to change the password of the sys account: -     ope

  • Forcing a UITableView to scroll down.

    I have a UITableView that needs to scroll down as I add more content. If my cell height is say 100, how would I force the table to scroll to the bottom cell if there are more than 5?

  • How to turn of music playing on iPad 2

    HOW DO I TURN OFF THE MUSIC  PLAYING ON MY IPAD 2.    ! post this few min. ago, did not type the word  off correctly.

  • Error Bad guess(es) on Hp 50g

    Hi, when i try to use solve complex numbers on solve equation this msg is show to me 'error bad guess(es)  one example is... 'y = G+B*i' the 'i'  is the imaginary number (B ) and the real number is G  so i put on solve equantion G  = 5  and  B = 0,00

  • TS4026 my mail does not load

    I my .mac mail fails to load.  What can I do?