3

I have a web application - But when I navigate from menus and other links, the address bar displays folder and file name. What I would like to have is whatever navigation the user do, the address bare should only display

http://domain:port/daswebapp

rather than

http://domain:port/daswebapp/admin/index.jsp

Can anybody help on this. I don't use any other framework.Its a pure MVC pattern. Thanks n Regards Noufal

jmj
  • 237,923
  • 42
  • 401
  • 438
Noufal
  • 41
  • 1
  • 2
  • I guess you could use framesets, or use Ajax/DHTML to load all pages. But why? How important is this for you (and your users)? – Thilo Jan 03 '13 at 06:32
  • Hi Jigar ,Thanx for response. The reason is in the address bar servlet name will be shown like http://domain:port/daswebapp/servletname without extension. if user enters in the address bar it will show exception. – Noufal Jan 31 '13 at 08:28

3 Answers3

0

Use url rewrite filter such as urlrewritefilter, for JSF based app go for Pretty faces

The main things it is used for are:

  • URL Tidyness / URL Abstraction - keep URLs tidy irrespective of the underlying technology or framework (JSP, Servlet, Struts etc).

  • Browser Detection - Allows you to rewrite URLs based on request HTTP headers (such as user-agent or charset).

  • Date based rewriting - Allows you to forward or redirect to other URL's based on the

    date/time (good for planned outages).

  • Moved content - enable a graceful move of content or even a change in CMS.

  • Tiny/Friendly URL's (i.e. blah.com/latest can be redirected to blah.com/download/ver1.2.46.2/setup.exe)

  • A Servlet mapping engine (see Method Invocation)

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
  • But then it would still show some URL unique to the page (just a different one). I don't think that can be helped, though. – Thilo Jan 03 '13 at 06:29
  • @Thilo _What I would like to have is whatever navigation the user do, the address bare should only display "http://domain:port/daswebapp" rather than "http://domain:port/daswebapp/admin/index.jsp"_ based on this it clearly seems that OP is looking for rewrite filter – jmj Jan 03 '13 at 06:33
  • If you say so. My understanding of a rewrite filter is that navigating to different pages still ends up as different URL, so the address bar would display different things depending on what navigation the user does. – Thilo Jan 03 '13 at 06:42
0

you can use RequestDispatcher,

RequestDispatcher dispatcher = getRequestDispatcher("daswebapp/admin/index.jsp");
   dispatcher.forward( request, response );
Narayan Subedi
  • 1,343
  • 2
  • 20
  • 46
0

you can use something like this try out and let me know

RequestDispatcher reqDisp = getServletContext().getRequestDispatcher("/index.jsp");
            reqDisp.forward(request, response);
Mathias Stavrou
  • 871
  • 1
  • 8
  • 16