Forums Register Login

How to hide the Jsp page name?

+Pie Number of slices to send: Send
Hi all I am new to jsp and servlets i have doubt about the name display in URL.
When i am observing some websites the name of the page will not appears in the URL but when i am clicking links or buttons in my application my JSP page names displays in URL how to avoid it?

ex:
  • http://localhost:xxxx/ComplexSearch-malli-context-root/login.html?reload
  • http://localhost:xxxx/ComplexSearch-malli-context-root/complexsearch.jsp

  • +Pie Number of slices to send: Send
    You should really use servlets as controllers. You control your url with mapping a url to a servlet in web.xml and redirecting from that servlet to your JSP.
    +Pie Number of slices to send: Send

    Link to your servlet from your <a> tag.
    like this

    Assuming you have mapped your servlet correctly.
    Then the servlet handles the display by using RequestDispatcher object.
    Then forwards your request and response to your jsp page.

    lets say your servlet is named ResultServlet
    here is the sample code in a servlet


    It will display the result.jsp upon succesful load.
    Hope this helps.


    +Pie Number of slices to send: Send
    Yes i used servlet as a controller


    And it is displaying the jsp name(studentinformation.jsp) in address bar of my browser
    1
    +Pie Number of slices to send: Send
    Ok, I can work with this.

    First of all, there is a huge difference between

    and


    Basically, the former will send a response to the browser telling him to make a new request to that page. The browser will create a new request to the JSP you mentioned in your method call, and you have essentially used no controller to go to the page.

    The latter will NOT send the response directly to the browser, but it will redirect your request to the jsp page, keeping all your request parameters and attributes, and not updating your url bar so the address you mapped your servlet to is used as the url in the browser bar.

    You should almost always use the latter.
    +Pie Number of slices to send: Send
    Is there any other way?
    And what about login page and home page
    I used RequestDispatcher but it displaying Servlet Name
    +Pie Number of slices to send: Send
    that is the way you do it. You can direct your home page to a servlet. You shouldn't link to a login page.

    It is displaying the servlet name because you're using the servlet name as a URL-mapping in your web.xml.

    In your web.xml, you'll have the following elements:



    The url you want to link to, the url you want to appear in your browser, is the <url-pattern> tag. You just change its content to what you want to display in your browser bar.
    +Pie Number of slices to send: Send
    It is also showing the action name i have used in my servlet appended at the jsp page
    like
    <c:url value="masterdetailservlet?action=employeeShow&DEPTNO=${dept.DEPTNO}" var="urlCurr"/>

    else if(Action.equals("employeeShow")){

    ------
    -------
    }
    it is showing in URL like ..../../../action=employeeShow&DEPTNO&XXXXX
    +Pie Number of slices to send: Send
    Is there any methode or something like post (which we actually used in servlets) in JSP (Not for form) for hiding data sending from jsp to servlet
    +Pie Number of slices to send: Send
    I think you're confused as to what JSP actually is. A JSP is basically a servlet that writes HTML to its outputstream. What you actually is comprised of HTML, JSP is not a markup language, it's a server-side technology. Perhaps it is best to read a course book or follow some tutorials to learn how to work with JSP.
    +Pie Number of slices to send: Send
    I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 8015 times.
    Similar Threads
    login-config not prompting for user id and password
    Default Server port assignments in WSAD
    AJAX Problem in JSP
    About JAMon Usage
    Welcome Filelist - with Spring
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Apr 16, 2024 08:01:59.