File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes http status 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "http status 404" Watch "http status 404" New topic
Author

http status 404

polavarapu prasad
Greenhorn

Joined: May 16, 2012
Posts: 2
when i fill form and submit .its say The requested resource (/minipro/checcking) is not available
i have to complet my project please help to solve this problm

thanks inadvance.
update:

<html>
<body bgcolor=paleblue>
<center><br><br><br>
<form action="http://locahost:8090/minipro/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
</center>
</body>
</html>

<web-app>
<servlet>
<servlet-name>checcking</servlet-name>
<servlet-class>checking</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>checcking</servlet-name>
<url-pattren>/checcking</url-pattren>
</servlet-mapping>
</web-app>



checcking:

import java.io.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;
public class checcking extends HttpServlet
{
Connection con;

public void init(ServletConfig sc)throws ServletException
{
super.init(sc);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbcdbcdbms","system","oracle");
}catch(Exception e){ System.out.println(e);}
}

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{

res.setContentType("text/html");
PrintWriter pw=res.getWriter();

String s1=req.getParameter("id");
if(s1==null|s1.equals(""))
{
pw.println("<body bgcolor=red>");
pw.println("<h1 align=left> error please enter user id...</h1>");
pw.println("<a href='update.html'><h3>click</h3></a>");
return;
}
try
{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select userid from logindetails where userid=' "+s1+" ' ");
while(rs.next())
{
String s2=rs.getString(1);
String s3=rs.getString(2);
}
if(s1.equals("s2"))
res.sendRedirect("billdetails.html");
else
res.sendRedirect("fail.html");
}

billdetails.html

<html>
<head><center>
<h3>Enter user bills </h3>
</head></center>
<body bgcolor=lime>
<center>
<form action="http://localhost:8090/minipro/billdetails">
<pre>month :<select name=month>
<option value=January>January
<option value=Febrauay>Febrauay
<option value=March>March
<option value=April>April
<option value=May>May
<option value=June>June
<option value=July>July
<option value=August>August
<option value=September>September
<option value=October>October
<option value=November>November
<option value=December>December</select><br>
Current bill :<input type=text name=current size=20><br>
Phone bill :<input type=text name=phone size=20><br>
Net bill :<input type=text name=net size=20><br>
Water charges :<input type=text name=water size=20><br>
Maintainance :<input type=text name=maintain size=20><br>
<input type=submit name=sumbit value=submit>
</pre></td></tr></table></center></form></body></html>



catch(Exception e1){ System.out.println(e1);}
}
}

fail.html:

<html>
<body bgcolor=lime<br><br>
<center>
<h3>you entered wrong user id.</h3>
<a href="update.html">click here</a></center>
</body>
</html>
billdetails

import java.io.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;

public class billdetails extends HttpServlet
{
Connection con;
public void init(ServletConfig sc)throws ServletException
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbcdbcdbms","system","oracle");
}catch(Exception ee){System.out.println(ee);}
}

public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
{
String s1=req.getParameter("month");
String s2=req.getParameter("current");
String s3=req.getParameter("phone");
String s4=req.getParameter("net");
String s5=req.getParameter("water");
String s6=req.getParameter("maintain");

/*create table billdetails(month varchar(10),currentbill number(7),phonebill number(7),
netbill number(7),waterbill number(7),maintaincebill number(7)); */

try{
PreparedStatement pst=con.prepareStatement("insert into billdetails values(?,?,?,?,?,?)" );

pst.setString(1,s1);pst.setString(2,s2);pst.setString(3,s3);pst.setString(4,s4);
pst.setString(5,s5);pst.setString(6,s6);
pst.execute();

}
catch(Exception e)
{System.out.println(e);}
PrintWriter pw=res.getWriter();
res.setContentType("text/html");
pw.println("<B>inserted.into table..");
}
}

William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Welcome to the ranch.

What container are you using?

WP
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

Please put your code in Code block. Edit your post to do so.

P.S.:- Not related to the solution of your query but related to Naming Convention, why the name of the Class (Servlet) in small? It should always be capital as per the standards.
)


Palak Mathur | My Blog | TechJaunt | What is JavaRanch? | List of All FAQs
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
Hello

Check your servlet class name in web.xml and the class name in your servlet class





It would be better if you follow MVC architecture. Separate persistence logic from servlet

There is a lots of error in your code. Check it properly.


kunal
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5


All classes used in servlets should be in a package - the reason being that the JVM looks for bare classes in the "current" directory - something you have no control over in the servlet environment.

Bill

Java Resources at www.wbrogden.com
Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112

hai..
It is not recommended to override the init(-) lifecycle method rather than you initialise your jdbc objects in init() method which is not life cycle and internally called by init(-).though you can use init(-) in your servlet program it is not recommended and also not industry standard..init() is not lifecycle method but is the convenience method given to programmer to place programmer choice initialization logics by overriding the iniit(-).
Servlet container doesn't call init() directly for instantaiation event.it is internally called by init(-).. if you verify the source code you can easily understand the various scenarios..






SCJP5
Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112




<html>
<body bgcolor=paleblue>
<center><br><br><br>
<form action= "http://locahost:8090/minipro/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
</center>
</body>
</html>

give the url patter of your servlet class.use relative url than using absolute url.. moreover please see that there are no spelling mistakes.. it is localhost not locahost.please also see that the deployment directory structure is correct before you run your applicaton.. your servlet program should reside in classes folder and html program inside web root folder parallel to WEB-INF. you get 404 status code when your deployment directory structure is wrong or when you give wrong url pattern at browser window.. please check it once.

try to change your for page as below:

<form action= "/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

That will not work. The action must start with the context path preceding the servlet path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sailaja koney
Greenhorn

Joined: Dec 18, 2011
Posts: 13

<url-pattren>/checcking</url-pattren>

please check the spell of <url-pattren>

probably this can also be an issue.....


sailaja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: http status 404
 
Similar Threads
how to find which servlet invoked the next
No exceptions but getting problem while storing data(Servlet and JDBC)
JDBC code with type 1 driver not working
servlets using JDBC
Code Review - ChatServlet