This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Servlet 3.0 annotations and web.xml welcome-file tags

 
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am doing a Servlet assignment where the servlet annotations are in the servlet file so there is no web.xml. To use a non-standard welcome-file I have made a web.xml with only the welcome-file tags in it but the web app ignores the web.xml. If I add an index.jsp or index.html to the project it loads fine. If I type the name of the welcome file into the URL the project is fine, it just won't initialize on the non-standard jsp file. The project works and the pages and servlets call each other correctly I just can't get the opening page to be called.





The url works fine



 
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try /login.jsp
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Try /login.jsp



does not work.

I confirmed that the change in the web.xml did get deployed to tomcat.
 
Marshal
Posts: 27286
87
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

margaret gillon wrote:The project works and the pages and servlets call each other correctly I just can't get the opening page to be called.



So what happens instead?
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bear Bibeault
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To verify whether the web.xml is being loaded, add a display-name element, such as:

<display-name>My Fabulous Web App 1.0.0</display-name>

Restart the web app, and see if the display name shows up in the list view of the Tomcat Manager application.

I also assume you've checked the logs?

Another thought (grasping at straws): you've got a lot of whitespace in there. I have no idea if it's significant or not, but I'd format it as:without all that extraneous whitespace.
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the localhost access log


Bear, I took out the white space and added the <display-name>My Fabulous Web App 1.0.0</display-name> line to the web.xml , then I rebuilt the war and redeployed. No difference on what I'm seeing.
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I double checked and the web.xml was in the wrong directory when the war unpacked. In the Tomcat directory I manually moved the web.xml to the correct sub directory and restarted the app. Now I see the display name in the Display Name column of the tomcat manager app but the application is still not loading the login.jsp and it gets the error when I open it from the tomcat manager that is showing the display name.
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, the web.xml works now. I wiped it out from tomcat and made sure there were no extra web.xml anywhere in the subdirectories. Fixed the build.xml so the web.xml was built into the correct directory in the war file, rebuilt the war, and then restarted everything, again. Now I have the Display Name in the tomcat manager AND the app loads correctly launching the login.jsp. As always Thanks, Bear.
 
Bear Bibeault
Sheriff
Posts: 67650
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
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Noooooooooooooo!!!



The right page (login.jsp) loads when the project opens but all the @WebServlet annotations don't work and when I submit the login tomcat cannot find the servlet. It seems like tomcat will use the web.xml OR the servlet annotations but won't work with both.... it's not fair........
 
Bear Bibeault
Sheriff
Posts: 67650
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
Hmm, I do not believe that is supposed to be the case. (Not a Servlet 3 user.)

Are there structural issues with the remainder of the app?
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is an odd project. It is for the Cattle Drive. I had to take the instructor's solution from the Videos 4a assignment and modify it by adding more classes and forcing a user login and security routines. The classes are inner classes. The project uses the javaranch.actionServlet class.

This morning I added the servlet mapping to the web.xml and the project runs as it should.
 
margaret gillon
Ranch Hand
Posts: 338
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My nitpicker had me try using the servlet as the welcome file and that works fine with the @WebServlet annotation.

the annotation


the web.xml


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic