Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Servlet Path Format to provide in RequestDispatcher

Avatar

Level 2

Hi All, 

 

Can Anyone Provide me a working Solution for below :

 

I need to forward servlet request from Servlet 1 to Servlet 2.

RequestDispatcher rd = request.getRequestDispatcher("/com/testform");
rd.forward(request, respo);

 where "/com/testform" is my Servlet 2 Sling Path.
It's not able to forward and seems like not able to find this above path.
Please provide me a working solution ASAP.

1 Accepted Solution

Avatar

Correct answer by
Level 6

@PriyankaDatta 

Best practice to register a servlet is using resource type. If you still want to go with path, then by default only '/bin/' is allowed in the OSGI sling servlet resolver and dispatcher.any file. So please check whether the path '/com/testform/' is allowed on both the places.

0 Replies

Avatar

Level 3

A Single request can be created once at a time. In your case, you are trying to create multiple servlet requests.

Avatar

Level 2

No.

Please check RequsetDispatch implementation and how to redirect request from one servlet to another.

Avatar

Level 2

@Shivam153 

Hi, I don't find here creating multiple servlet request.

If you can check the code snippet above,

 This is the syntax that we follow .

To forward any servlet request from one to another, it involves 2 steps as below:

1. Create request dispatcher object (here it is 'rd')

2. and use that object in forward method.

 

RequestDispatcherOBJECT.forward(SlingRequest, SlingResponse)

Avatar

Correct answer by
Level 6

@PriyankaDatta 

Best practice to register a servlet is using resource type. If you still want to go with path, then by default only '/bin/' is allowed in the OSGI sling servlet resolver and dispatcher.any file. So please check whether the path '/com/testform/' is allowed on both the places.

Avatar

Level 3

hello @PriyankaDatta ,

Hope you have already got the solution for the above. If not please check the below Url if it helps

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/calling-a-servlet-from-ano...

 

Please make sure your servlet path is configured as allowed paths in the Configuration Manager