You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by pawan <pa...@apar.com> on 2003/05/20 07:19:54 UTC

Problem with Servlet Forwarding...help appreciated.......

Hi,

ANY HELP IS APPRECIATED...

I am using Tomcat 4.1.24, Win 2000, Oracle 8i

here is my directory structure :-

shyam(which is my context root)
|
|___jsp
|       |____ams
|               |_____<my files in this directory>
|
|___servlets

now let say my url is:

http://localhost:8080/shyam/jsp/ams/viewAccount.jsp

This jsp has a form which actually sends this request to
viewAccountDetail.js... I am using this action :-

action="<%= request.getContextPath()
%>/manageAccount/viewAccountDetail.jsp">

now here "manageAccount" is just a keyword which i am using for url mapping
in my web.xml file....and its calling my controller servlet....which is
working fine. Now this servlet creates an instance of my bean
"AccountData.java" and then i have to forward this request to the actual
"viewAccountDetail.jsp"

http://localhost:8080/shyam/jsp/ams/viewAccountDetails.jsp

to forward i am using :

req.getRequestDispatcher("/jsp/ams/viewAccountDetail.jsp").forward(req,
resp);

Its finding the targeted page as i can see some console output but the url
in the browser doesn't change. It remains
http://localhost:8080/shyam/manageAccount/viewAccountDetail.jsp

Because of this my page is not able to load any images or style sheet.... so
how can i change actual url in the browser address bar????


Please show me a way or an alternate way to achieve this MVC.

Thanks In Advance

Pawan


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Problem with Servlet Forwarding...help appreciated.......

Posted by Sriram N <sr...@yahoo.com>.
--- pawan <pa...@apar.com> wrote:
> Hi,
> 
> ANY HELP IS APPRECIATED...
> 
> I am using Tomcat 4.1.24, Win 2000, Oracle 8i
> 
> here is my directory structure :-
> 
> shyam(which is my context root)
> |
> |___jsp
> |       |____ams
> |               |_____<my files in this directory>
> |
> |___servlets
> 
> now let say my url is:
> 
> http://localhost:8080/shyam/jsp/ams/viewAccount.jsp
> 
> This jsp has a form which actually sends this request to
> viewAccountDetail.js... I am using this action :-
> 
> action="<%= request.getContextPath()
> %>/manageAccount/viewAccountDetail.jsp">
> 
> now here "manageAccount" is just a keyword which i am using for url mapping
> in my web.xml file....and its calling my controller servlet....which is
> working fine. Now this servlet creates an instance of my bean
> "AccountData.java" and then i have to forward this request to the actual
> "viewAccountDetail.jsp"
> 
> http://localhost:8080/shyam/jsp/ams/viewAccountDetails.jsp
> 
> to forward i am using :
> 
> req.getRequestDispatcher("/jsp/ams/viewAccountDetail.jsp").forward(req,
> resp);
> 
> Its finding the targeted page as i can see some console output but the url
> in the browser doesn't change. It remains
> http://localhost:8080/shyam/manageAccount/viewAccountDetail.jsp
> 
> Because of this my page is not able to load any images or style sheet.... so
> how can i change actual url in the browser address bar????
> 

Does this servlet which writes output to the console also display anything on
the browser page ? If this is so, then you're doing just fine. The URL will not
change when you forward control to other servlets. When you "forward", you're
"forwarding" control to another servlet, and letting the new servlet handle the
output generation.

How are you referring to the stylesheets in the HTML pages ?

> 
> Please show me a way or an alternate way to achieve this MVC.
> 

Consider using the Jakarta Struts Framework. It may take you a few days to get
used to this, but it's worth the efforts.

Please also post Servlet API queries to the Servlet Interest mailing list.

Also, topics such as Request Forwarding and Request Dispatching are explained
in the Servlet API Specification.

> Thanks In Advance
> 
> Pawan
> 

-- Sriram

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org