Question

As I am running the code in localhost mode and I have localhost:8080/url/hello. Is the value after / is the directory or the path Because I am getting the result as HTTP STATUS 404.

   public void onValueChange(ValueChangeEvent<String> event)
{

           String a=Window.Location.getHref();
           Window.alert(a);     
        if(Window.Location.getHash().equals("") || Window.Location.getHash().equals(null) || Window.Location.getHash()== null)
        {
            String SUBURL=a.substring(a.lastIndexOf("/")+1;
                String a1=SUBURL;
                Window.alert("LINK :: "+a1);

            if(!a1.isEmpty())
            {
                greetingService.shrturl(a1,new AsyncCallback<String>()
                  {

                   @Override
                   public void onFailure(Throwable caught) 
                    {

                     Window.alert("fail");

                    }

                    @Override
                    public void onSuccess(String h) 
                    {
                        System.out.print("return value :: "+h);
                        if(h.equals(null))
                        {
                            Window.Location.replace("ERROR:PAGE NOT FOUND");
                        }
                        else
                        {
                             Window.Location.replace(h);
                        }
                    }

                  }); 
            }
            else
            {
                new shorturl();
            }
        }
Was it helpful?

Solution

Localhost: is telling the server to loop back on itself, so instead of sending a HTTP request to a forgien server to send it to a local server,

8080:, refers to the port number,

/url/hello/ refers to the directory structure within the local server

so yes if you are migrating your code from local to live then

http://localhost:8080/url/hello

will become

http://www.mywebsite.ie/url/hello
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top