Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

weird functioning of servlet

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

First i will paste all my code here.

DataPage.jsp


DataServlet.java


This two are dependent on each other, wright? I have other jsp page which is dependent on other servlet. Code is below


Insert.jsp


Insert.java



Now. The insert.jsp works fine, when I give data and click add button, the database is also updated. Till here its fine

THE PROBLEM:
In DataPage.jsp I am viewing the list sent by the servlet "DataServlet". So if i run the DataPage.jsp directly I get an error at the itterator. However, I accessed the DataServlet from the browser then i get this error "HTTP method GET is not supported by this URL" which i used to not get in the beginning. This started after I added the Insert.jsp and Insert.java files. I am unable to solve it. Someone please point out the problem.


Thanks and regards
Adeeb
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey i missed this point. I tried to access DataServlet from different jsp file using a submit button and form with method as post and all.. Here the URL Shows up with /mypath/DataServlet. But the most annoying thing is its not behaving as it should i.e displaying database table by redirecting to DataPage.jsp, as the code is written, instead it shows the window of same Insert. NOTE:In URL name is DataServlet, but it shows Insert page. How come??? I restarted Apche many times, recompiled the code. Dont know the problem. Please help me out.


Thanks.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

adeeb alexander wrote:In URL name is DataServlet, but it shows Insert page. How come?


You are forwarding from the servlet to the JSP. So why is this a surprise? It's doing exactly what you told it to do.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is I dint know about xml tags. I wrote like this
<servlet>
<servlet-name>DataServlet</servlet-name>
<servlet-class>DataServlet</servlet-class>

<servlet-name>Insert</servlet-name>
<servlet-class>Insert</servlet-class>
</servlet>

instead of writing individually.
I was surprised cauz, even the URL was wright, but page displayed was different..
Now its resolved. Thanks.

 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic