• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and Form Problem  RSS feed

 
Elton Hughes
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am new to Java, and servlets and JSP. I am 170 pages into "Murach's servlets and JSP". This is the first time I have had any problems with the examples/exercises. I am using Tomcat 4.1.27 in a standalone mode.
Here is my problem:
join_email_list.html is a smple html page requesting email data. It calls a servlet, servlet/coreservlets.EmailServlet. The data is processed and the results are passed to a JSP called show_email_entry.jsp which displays the processed data. So far so good. It works.
At the bottom of show_email.jsp is:

When I click on the Return button, I get a 404 error stating that /servlet/join_email_list.html is not available. True, that page is three directories up from servlet. In fact, the JSP and HTML pages are in the same directory
Ok, I thought that it would look in the same directory for that html page. Why is it looking in the servlets directory?
Elton
p.s. Am I in the right forum for this question?
[ October 08, 2003: Message edited by: Elton Hughes ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Relative URIs will be computed from the current URI which in this case is not the same as the folder from which the JSP is being served. In a servlet environment, you either need to use absolute or server-relative URIs, or make use of the <base> html tag to set a relative base.
hth,
bear
[ October 08, 2003: Message edited by: Bear Bibeault ]
 
Elton Hughes
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Thank you for your suggestion. It helped me find the solution.
My first step was to change the address in the form to an absolute path. Oddly, that did not work. But I could see in the address box, that the JSP had the address as localhost:8080/(and the entire absolute address). Hmm. Well I wanted it to go to localhost:8080/join_email_list.html so I changed the address in the JSP to /join_email_list.html and that solved the problem.
Elton
[ October 08, 2003: Message edited by: Elton Hughes ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!