Posts

Showing posts from July, 2024

First JSP Program

Image
 1. Click on Project (in my case JspDemo is my project)  2. Now click on src---> main --->Select WebApp folder 3. Now right click on webApp folder and click New--->Jsp File 4. Rename that jsp file with meaningful name (Example i give Login.jsp) 5. Click finish So your JSP file is created  Here you can write java code inside scriptlet tag  Now select project and right click after run---> run on server Select tomcat and click next after configure your project and click finish Now jsp page is running on server in url write your jsp page name and click enter  so your web application is live

How to Integrate tomcat into eclipse

Image
 Step 1 : Open eclipse IDE for EE and Web developer           Step 2 : Press Control +N Step 3 : On Wizards type Dynamic Web Project ---> Select ---> Click Next  Step 4 : Give Project Name (I write my project name is JspDemo) Step 5 : After writing project name click next Step 6 : again Next Step 7 : You must check Generate web.xml and click finish Step 8 : Now on left side JspDemo project is created  Step 9 : Open google and type Apache tomcat 10.1download   click on first link              click on 64 bit windows zip After downloading extract that zipped folder Step 10 : Now click on Servers tab  Next select appropriate version of tomcat (in my case i select tomcat 9.0) Click next Click on browse button  Click on Select Folder Click on Next Select your project & Click add after Click finish Now your tomcat server is successfully integrated to eclipse IDE

Eclipse for EE and web application

Image
 Step 1 : Go to google and type                       "eclipse EE for java and web developer" Step 2 : Click on first link Step 3 : Click on Download option in next page                                     Step 4 : Click option Install eclipse for EE and Web Developer

JSP tutorials for beginner

 Pre-requisites :      1. you have installed eclipse IDE (eclipse for EE and web application)           Click here to see complete downloading and installing guide.     2 . you have Apache tomcat (either tomcat 9.0 or 10.1 depends on your system configuration)          Click here to see complete downloading and installing guide.     3. First JSP Program           Click here to see steps      3. you have installed Mysql Database.           Click here to see complete downloading and installing guide.      4. you need to download Mysql connecter software.           Click here to see complete downloading and installing guide.

Strps to create Dynamic Web Project for JSP

 3. SRC Folder ----> main folder -----> Web App Folder  4. We select that Webapp folder and right click -----> New ---> Html File

First JSP Page

JSP Code  <%@page import="java.sql.ResultSet"%> <%@page import="java.sql.Statement"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.DriverManager"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"     pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head> <body> <% String s1 = request.getParameter("T1"); String s2 = request.getParameter("T2"); try{ Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/harish", "root", "root"); Statement st = conn.createStatement(); int a = st.executeUpdate("insert into register values('"+s1+"','"+s2+"')"); ...

Simple Servlet code

 Html Code <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Login Screen</title> </head> <body>       <form action="/B14/Login" method="get">         <div>             <label for="username">Enter Number:</label>             <input type="text"  name="T1">         </div>         <br>                 <div>             <input type="submit" value="Print Table">         </div>     </form> </body> </html> ==================================================== Servlet Code import java.io.IOExcep...

Servlet

Image
For creating dynamic web application you required to follow that steps 1.      Open Eclipse  2. Press Control + N 3.  4.  5. 6. 7.  8. Steps to configure apache tomcat servler into eclipse 1. 2. 3. 4. 5. 6. 7. 8. 9.