• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How do I get the RequestDispatcher to forward to the desired jsp which is in a seperate folder?  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use requestdispatcher to forward to a jsp inside another folder. None of them are in the WEB-INF folder. The problem is that it will show it redirected as the tab will show the title of the desired page but the url shows that of the servlet and the page is blank.
File system is (all under Web Pages not WEB-INF):

current jsp: Web Pages/index/index.jsp
desired jsp: Web Pages/admin/monster-html/admin.jsp

![picture of problem](https://i.ibb.co/B6K8TZn/Screenshot-14.png)

I tried:

This got me to that page displayed
```
request.getRequestDispatcher("/admin/monster-html/admin.jsp").forward(request, response);
```
this got me to an error page
```
RequestDispatcher requestDispatcher = request.getRequestDispatcher("//admin/monster-html/admin.jsp");
requestDispatcher.forward(request, response);
```
this too got me to an error page
```
response.sendRedirect("//admin/monster-html/admin.jsp");return;
```
this got me to a 404 error page
```
response.sendRedirect("/admin/monster-html/admin.jsp");return;
```

Ialso tried jsp mapping

```
<servlet>
       <servlet-name>admin</servlet-name>
       <jsp-file>/admin/monster-html/admin.jsp</jsp-file>
   </servlet>
   <servlet-mapping>
       <servlet-name>admin</servlet-name>
       <url-pattern>/admin</url-pattern>
   </servlet-mapping>
```

here is what I have currently
```
request.setAttribute("projects", projects);
request.setAttribute("sme_pending", sme_pending);
request.setAttribute("complaints", complaints);
request.setAttribute("freelancers_pending", freelancers_pending);

RequestDispatcher requestDispatcher = request.getRequestDispatcher("/admin/monster-html/admin.jsp");
requestDispatcher.forward(request, response);
```

I want to call the admin.jsp and use the request too.
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!