• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

securing resources in webcontent except for css and javascript.

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ranchers,
I am writing a new web application in websphere 7. My webcontent has jsps, css and javasript files. I do not want to allow the user to directly access the content here like when they type
http://locahost:9081/TestApp i want to redirect the user to my servlet(bascially I want to redirect the user to my default servlet, other than if the request is for css or javascript). I am a little lost here. Basically the authentication is done in my servlet, so untill the control gets to my servlet, i have no way of knowing if the user is authenticated.

I would appreciate if anyone can throw some light on this,

Thanks.
 
Sheriff
Posts: 28325
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand the problem here. What do the CSS and javascript files have to do with authentication?
 
John Robert
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I don't understand the problem here. What do the CSS and javascript files have to do with authentication?

.
I am a little new to web apps,
may be I dint put the question right. I will try again. If I put a mapping in web.XML saying forward any request to my one servlet, what would happen when a request comes for JavaScript or Css file? My servlet dispatches the request to a jsp. The jsp has javasript and css files linked( the javasript is in a file outside the jsp).When the browser tries to retrive the JavaScript file , would it get back the JavaScript file or would it get forwarded to the servlet because I said in my web.XML forward any request to this servlet?
 
Paul Clapham
Sheriff
Posts: 28325
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Robert wrote:If I put a mapping in web.XML saying forward any request to my one servlet, what would happen when a request comes for JavaScript or Css file?


This request would be directed ("forwarded" isn't the right word, that refers to something else) to that one servlet. If the request is for a URL ending in ".css" or ".js", or ".html", or whatever else, just forward the request to that resource. Otherwise do your authentication and so on. At least that's what I did; this question isn't specific to Websphere, it applies to anything using the servlet spec, so I'm going to move the question to the Servlets forum. It might get a better answer there.

(By the way this sort of thing is normally done in a filter these days, rather than a front controller servlet.)
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a filter, not a mapping.
 
John Robert
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Olk I will look into filters and use it. Thanks for the help.
 
Everybody! Do the Funky Monkey! Like this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic