• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

linking to a jsp page instead of linking to an action

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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

Thanks
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Thanks
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?



Ok, I understand now.
but i m able to access jsp pages under WEB-INF
http://localhost:8080/Final_Project/catalog.action will actually take me to the product page???

Thanks

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The *browser* is not able to access resources under WEB-INF. The *server* can.
 
Sammy Bill
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:The *browser* is not able to access resources under WEB-INF. The *server* can.



when i do http://localhost:8080/Final_Project/catalog.action.

isn't that accessing it through the browser?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

No. The browser is accessing the action URL. The *server* is accessing the JSP.
 
Sammy Bill
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:...

No. The browser is accessing the action URL. The *server* is accessing the JSP.



Sorry If i m misunderstanding that last part.

When I do http://localhost:8080/Final_Project/login.jsp it works fine.
and when i do http://localhost:8080/Final_Project/catalog.action it works fine too.

so Why i m acessing the action URL and the JSP from WEB-INF.

Sorry, I might be overlooking the answer.

Thanks a lot for you time
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You wrote:When I do http://localhost:8080/Final_Project/login.jsp it works fine.


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.
 
Sammy Bill
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:

You wrote:When I do http://localhost:8080/Final_Project/login.jsp it works fine.


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:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, okay; that makes more sense :)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic