I have a products.jsp page that displays the products stored in the database.
to get to that page, i have to click a link in the home page that says:
<a href="catalog.action">products</a>
then it will processes the action and call products.jsp.
but when i go directly to prducts.jsp by typing the url to the jsp page ( not the action), i get no products.
I understand that when i go to products.jsp directly, i m not callin the action.
is there anyway that i can have localhost:8080/proj/products.jsp call the action and return the result to the products.jsp
without typing localhost:8080/proj/catalog.action
is there anyway that i can have localhost:8080/proj/products.jsp call the action and return the result to the products.jsp
without typing localhost:8080/proj/catalog.action
Why do you want to do that ? Check out Logic:redirect , if that could help you.
Also where did you place the jsp ( cannot be under WEB-INF)
Sammy Bill
Ranch Hand
Joined: Dec 29, 2008
Posts: 96
posted
0
Balu Sadhasivam wrote:
is there anyway that i can have localhost:8080/proj/products.jsp call the action and return the result to the products.jsp
without typing localhost:8080/proj/catalog.action
Why do you want to do that ? Check out Logic:redirect , if that could help you.
Also where did you place the jsp ( cannot be under WEB-INF)
1) I want to allow the user to type the url localhost:8080/ProjName/products.jsp. and get the list of the products in the database.
The way i m doing it is through a link that will call the action then it will display the products.jsp page. so the user will have to click
a link to get to that page.
2) why I can not place the jsp file under WEB-INF, thats what i m doing
Files under WEB-INF are not available to the browser.
In general, Struts apps should always access their pages through actions and avoid mixing "plain" JSP addresses. I don't understand why you'd want to do that either, or what's wrong with just typing "products.do" (or, in your case, the longer "products.action"). What's it matter? Why complicate things?
Sammy Bill
Ranch Hand
Joined: Dec 29, 2008
Posts: 96
posted
0
David Newton wrote:Files under WEB-INF are not available to the browser.
In general, Struts apps should always access their pages through actions and avoid mixing "plain" JSP addresses. I don't understand why you'd want to do that either, or what's wrong with just typing "products.do" (or, in your case, the longer "products.action"). What's it matter? Why complicate things?
In your JSP example URL the JSP isn't under WEB-INF.
In the action example URL the JSP *may* be under WEB-INF; I have no way of knowing.
The original point was that we didn't understand your requirement to use a JSP file as the URL (which in general you shouldn't do in a Struts app). The other point was that if a JSP is under WEB-INF the *browser* won't be able to access it directly.
Sammy Bill
Ranch Hand
Joined: Dec 29, 2008
Posts: 96
posted
0
David Newton wrote:In your JSP example URL the JSP isn't under WEB-INF.
That is what I did not understand, I m sure the login.jsp is under WEB-INF. and i can access it directly.
That JSP is not under /WEB-INF. It's either in the root (if you're deploying to the "Final_Project" app context) or under /Final_Project if you're deploying to the root context.
You may *have* a login.jsp under /WEB-INF, but it's not the one being served when you use the above URL.
That JSP is not under /WEB-INF. It's either in the root (if you're deploying to the "Final_Project" app context) or under /Final_Project if you're deploying to the root context.
You may *have* a login.jsp under /WEB-INF, but it's not the one being served when you use the above URL.
Sorry, Execuse my stupidity.
For some unknown reason, I was meaning WebContent when i refer to /WEB-INF.
Thank you very much for the clarification and for you time :thumbup: