my dog learned polymorphism*
The moose likes Struts and the fly likes Accessing Struts Servlet through welcome-file-list in web.xml ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing Struts Servlet through welcome-file-list in web.xml ??" Watch "Accessing Struts Servlet through welcome-file-list in web.xml ??" New topic
Author

Accessing Struts Servlet through welcome-file-list in web.xml ??

Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
Hey All,

This might be a easy one for most of you.

Currently, i am accessing the login page configured in welcome-file-list in web.xml. I am directly accessing the JSP.

Instead i would like to call the Struts component and then get redirected to the JSP.

When i tried to do this, i get a Error 403--Forbidden From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden


Any idea why this is happening ???

Replies will be greatly appreciated...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
What application server are you using? Show us your entry in the welcome file list of web.xml.


Merrill
Consultant, Sima Solutions
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
We are using Weblogic 8.1 SP4

Entry in web.xml

<welcome-file-list>
<welcome-file>/redirectDispatch.do?parameter=xxxxxx</welcome-file>
</welcome-file-list>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try removing the initial "/" from your welcome file entry, making it:

<welcome-file>redirectDispatch.do?parameter=xxxxxx</welcome-file>

The reason I asked you about your application server is that some application servers allow for a "virtual" welcome file (action.do is a virtual file, because there is no physical action.do file) and some do not. I use WebSphere, and it requires a physical welcome file, but WebLogic, from what others tell me, will allow a virtual file.
[ August 04, 2006: Message edited by: Merrill Higginson ]
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
THanks for the reply. I do have a Physical welcome file (class extending struts action servlet).

I made the change, but it does not seem to help.

Find below the message.


Error 403--Forbidden
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

[ August 04, 2006: Message edited by: Raj Verma ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
What I'm trying to explain in the virtual vs. physical file discussion is this: There is no physical file on your system named redirectDispatch.do. Look all you want... you won't find one. redirectDispatch.do is a URL that will cause the Action servlet to look for a specific Java class, but it is not a physical file.

The servlet spec indicates that items in the welcome file list should be just that... files, not URLs. I'm not a WebLogic user, but I have had colleagues tell me that WebLogic will allow a URL to work in a welcome file list even though the servlet spec doesn't require it. In your case, it looks like it's not working. There may be some security setting within WebLogic that may fix this, but I'm afraid I can't help you on that.

Here's the workaround:

change your welcome file list to index.html. Then create an index.html file with the following entry in the <head> section:

<META HTTP-EQUIV="refresh"
CONTENT="2;URL=redirectDispatch.do?parameter=xxxxxx">

This will cause the page to redirect to your struts action.
[ August 04, 2006: Message edited by: Merrill Higginson ]
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
Thanks for your detailed reply.

I did understood about the Physical file concept.

I tried to implement the way you have suggested and it worked fine.

My only issue is in passing a parameter. I cannot define a static value for the parameter as it is dynamic for each user.So, when i come to the index.html, i will have the value of the parameter in the HttpServletRequest and i need to append the value as a parameter to the URL.

I am trying to find the solution, but if you have any idea on top of your mind, it will also be great.

Thanks for your time.
[ August 04, 2006: Message edited by: Raj Verma ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In that case, I'd recommend you remove the index.html file and create an index.jsp file.

In index.jsp, you can use the <jsp:forward> tag and within that tag you can use EL or a scriptlet to get the parameter you wish to pass on.
[ August 04, 2006: Message edited by: Merrill Higginson ]
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
Thanks, Merrill. I got it working.
 
Don't get me started about those stupid light bulbs.
 
subject: Accessing Struts Servlet through welcome-file-list in web.xml ??