Home Answers Viewqa JSP-Servlet jsp using include & with mysql

 
 


Prateek Mishra
jsp using include & with mysql
1 Answer(s)      a year and 9 months ago
Posted in : JSP-Servlet

Sir,

I am creating a login application using jsp & Mysql. 

The Codes are---


Html File......


<html>
<head><title>LOGIN APPLICATION</title></head>
<body bgcolor="sky blue">
<font color="red"><b><blink>PLEASE ENTER THE USERID AND PASSWORD...........</blink></b></font>
<br>
<br>
<form method="get" action="login.jsp">
Enter UserId:<input type="text" name="userId"><br>
Enter Password:<input type="password" name="password"><br><br><br>

<input type="submit" value="LOGIN">
</form>
</body>
</html>


Jsp file.......

<%@ page import="java.sql.*" %>

<%

String mailid=request.getParameter("userId");
String password=request.getParameter("password");

Class.forName(application.getInitParameter("driverclass"));

Connection con=DriverManager.getConnection(application.getInitParameter("url"),application.getInitParameter("user"),application.getInitParameter("password"));

PreparedStatement stmt=con.prepareStatement("Select name from userinfo where mailid=? and password=?");

stmt.setString(1,mailid);
stmt.setString(2,password);

ResultSet rset=stmt.executeQuery();

if (rset.next())
{
    out.println("Welcome"+rset.getString(1));
}
else
{
    out.println("Invalid Userid Or Password.");

    %>

<%@ include file="login.html" %>

        <%
}
        out.close();
        %>



  WEB.xml...........

<web-app>

<context-param>
<param-name>driverclass</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>

<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost:3306/userinfo</param-value>
</context-param>


<context-param>
<param-name>url</param-name>
<param-value>root</param-value>
</context-param>

<context-param>
<param-name>url</param-name>
<param-value>root</param-value>
</context-param>

</web-app>

It will producing error like...........

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:164)
    org.apache.jsp.login_jsp._jspService(login_jsp.java:55)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

Please tell me the complete solution.


  Thanks,,,,
View Answers

August 8, 2011 at 1:21 PM


It seems that application doesn't find mysql connector jar file. Download it and put it into lib of jdk and in tomcat lib.

Please go through the following link:

JSP Login Application









Related Pages:
jsp using include & with mysql
jsp using include & with mysql  Sir, I am creating a login application using jsp & Mysql. The Codes are--- Html File...... <...; Jsp file....... <%@ page import="java.sql.*" %> <% String
include a jsp file
include a jsp file   Sir, I have 2 jsp pages. I want to include second jsp in the first jsp page when a button in the first jsp is clicked. how can I do this. I tried in sevaral ways . I am using jsp and javascript... anyone
Jsp include page problem
Jsp include page problem  I have included footer.jsp in all my pages. It is working in all pages except search.jsp. In search.jsp (Old footer.jsp... the cache files in your server's work folder. If you are using tomcat, then you
include a static file
include a static file  How will you include a static file in a JSP page?    You can include a static resource to a JSP using <jsp:directive > or <%@ inlcude >
How to include a File using directive and include action
; <h1>Using the include action</h1> <jsp:include page = "...How to include a File using directive and include action... one attribute named as file, which is used to include a file in the jsp page
difference between <%@ include ...> and <jsp:include>
difference between <%@ include ...> and   What is the difference between <%@ include ...> (directive include) and <jsp:include>
how to include a java class in jsp - JSP-Servlet
how to include a java class in jsp  hello sir, this is my first... to use those variables in my jsp for further process... ?? is it possible..?? suggestions are heartly welcomed.  Hi friend, Using
Passing Parameter with <jsp: include>
a file in a jsp page. While using <jsp:param> we are adding...--> <jsp:include page="AccessincludedParameter.jsp"> <jsp...Passing Parameter with <jsp: include>     
Include static files within a JSP page
using the JSP include directive. This way, the inclusion is performed just once...Include static files within a JSP page  How do I include static files... for the file attribute. Although you can also include static resources using
jsp:include page=.. and include file = ...
jsp:include page=.. and include file = ...   What is the difference between <jsp:include page = ... > and <%@ include file = ... >?.   <jsp:include page = ... >: This is like a function call from
Include Static HTML Page in JSP
in jsp. In JSP, there are two ways to include another web resource. 1. include directive and  2. jsp:include element. Using include directive inserts text... Include Static HTML Page in JSP   
JSP &MYSQL
JSP &MYSQL  Develop a web page for the telephone directory using jsp and mysql
JSP include directive tag
JSP include directive tag  What is include directive tag in JSP
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
JSP include directive tag
JSP include directive tag  What is include directive tag in JSP?   Hi, The JSP include directive includes a static file or sends a request to a dynamic file. or The JSP include directive is used to include
JSPs : include Directives
at translation time. The include directive is one part of JSP directives...-INF by using include attribute. Syntax - <%@ include file="url...JSPs : include Directives In this section we are going to discuss the include
Dynamic include jsp
Dynamic include jsp  I need dynamic include jsp page with an example
jsp include action tag
jsp include action tag  Defined jsp include action tag ?   The <jsp:include> element allows you to include either a static or dynamic... that is included in the JSP page. When the include action is finished, the JSP
JSP-Mysql - JSP-Servlet
JSP-Mysql  Hello friends, Anyone send me the way how to store image in mysql database from a jsp page.  Hi friend, Code to insert image in mysql Using Jsp : For more information on JSP
How to include?
How to include?  How can we include a JSP file in one application to the JSP file in another application which are in the same server?? please help me out with code
jsp and mysql
jsp and mysql  i have a form which contains dropdown list. i have to take the values to another jsp page and perform the calculation on the database which i have earlier using the values of the selected dropdown list
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
Include Tag (Data Tag) Example
) that we want to include in our main jsp page ie..includeTag.jsp. myBirthday.jsp...; tag includes another jsp using the value parameter ...Include Tag (Data Tag) Example      
include tag
include tag  good morning sir. This is venu sir.i am pursing mca . I am learning struts2 but i have a small doubt i am using include tag. ex... include tag ..... is not displayed Thanks venu
include tag
include tag  Good morning sir. This is venu sir.i am pursuing mca . I am learning struts2 but i have a small doubt i am using include tag. ex welcome to rose India.net include value="myBirthday.jsp" but only display
can we use include files in struts.....? - Struts
can we use include files in struts.....?  hi, i have a doubt that whether we should not redirect from one jsp to another jsp directly using include r jsp:include directives. I heard that it is violation of struts rules if we
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
Include directive vs Include Action
;) includes file into the JSP page at compile time. Include directive should be used...;jsp:include>) includes the output at runtime. Include action (runtime... Include directive vs Include Action   
jsp/mysql connection
jsp/mysql connection  I am puttng the following files in the lib folder of jdk to connect jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect jsp and mysql
jsp/mysql connection
jsp/mysql connection  I am puttng the following files in the lib folder of jdk to connect jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect jsp and mysql
JSP Include jsp
JSP Include jsp   ... include either a static or dynamic file in a JSP file. If the file is static, its...;Includes Jsp Page</h2> <jsp:include page="includedJsp.jsp" >
upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
include a delete option in every row of table in a JSP page
include a delete option in every row of table in a JSP page  I have the following code of a JSP page........... <blockquote> <p>&lt;%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> &lt
Jsp include directive
. By using the include tag the file will be included in the jsp page... to be included in the other jsp file by using the tag <%@ include file = " "...Jsp include directive      
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
JSP include
JSP include       A JSP page can include page fragments from other files to form the complete... the action:   <jsp:include page=" relative URL" flush="true"
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my... want csv file with 10 rows.. i want to do in jsp... pls help me soon..its very
The Include Directive in JSP Page
The Include Directive in JSP Page   ... directive of the JSP. You will learn about what is include and how to implement...; <%@include file="relativeURL" %> <jsp:include page="
connection of jsp with mysql - JSP-Servlet
connection of jsp with mysql  can anybody tell me about connection of JSP with MYSQL? and also tell me which version is compatible with tomcat 4.1 i am using tomcat 4.1, MYSQL 5.0 but i have problem with connection
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files... and password to enter into the Mysql database account.the other named...:THE LAST JSP PAGE IS COMING DIRECTLY ON EXECUTION IN TOMCAT
JSP using java - Hibernate
JSP using java  This is my part of Excal sheet code using jdbc... using hibernate.I am having function called displayIps() and displayvalues... to include displayIps() in place of rs.getString(1)and How to include displayvalues
get info from mysql using jsp and servlet
get info from mysql using jsp and servlet  HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too
JSP - MySQL - Connection
JSP - MySQL - Connection  I can't connect mysql using jsp in my... to resolve this problem.I set classpath for the mysql connector jar (/home/aghiltu/apache-tomcat-6.0.26/lib/mysql-connector-java-5.1.8-bin.jar)..... And i also tried
MySql - JSP-Servlet
MySql  Hello friends, I am developing a JSP project with back end MYSQL and i am using SQLYOG editor enterprise 7.11. I got the serial number also...; Hi friend, http://www.roseindia.net/mysql/mysql-front.shtml Thanks
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
Upload Exce Data into MySql Using Jsp and Servlet - JSP-Servlet
Upload Exce Data into MySql Using Jsp and Servlet  now i am doing... into Mysql Database table so please give the coding to me, it's very urgent for me... the following link: http://www.roseindia.net/jsp/upload-insert-csv.shtml Hope
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
flush attribute in jsp:include tag - JSP-Servlet
flush attribute in jsp:include tag  what is the use of flush attribute in jsp:include tag ?  hi friend, ------------------------------ Read for more information, http://www.roseindia.net/jsp
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.