Skip to main content

Posts

Showing posts from November, 2021

Session tracking using url rewriting in servlet

 Session tracking using url rewriting in servlet web.xml ======== <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">   <display-name>URLRewriting</display-name>   <welcome-file-list>     <welcome-file>index.html</welcome-file>   </welcome-file-list> </web-app> index.html ======= <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <style type="text/css"> div { width: 500px; margin: auto; margin-top: 100px; } </style> </head> <body> <div> <form action="firsturl" method="post">

Session tracking using Hidden form fields in servlet

Session tracking using Hidden form fields in servlet  Http Stateless behaviour ======================== The protocol http creates seperate connection with the web server for browser for every request due to this one connection data can not be used in another connection i.e one request data can not be used in another request processing. in order to get stateful behaviour in web application though protocol http is stateless we need to use following session tracking techniques a)Hidden form fields advantages ========== 1)Basic html knowledge 2)can be used with diff servers 2)Disadvantages a)we can see the data (no secrecy) b)hidden box values travel across the multiple requests i.e they increase network traffic  b/w browser and server c)Hidden boxes can only hold the text data/String values.. i.e they can not hold the java objects d)if multiple forms are there then adding hidden box values is quite heavy job Directory ======= web.xml ======== <?xml version="1.0" encoding=&quo

How to fetch and display data of html form in servlet?

 How to fetch and display data of html form in servlet? For explanation watch video:: web.xml ======== <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">   <display-name>ServetRequest</display-name>   <welcome-file-list>     <welcome-file>home.html</welcome-file>   </welcome-file-list> </web-app> home.html ========== <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <!-- jQuery

JDBC Auto Increment Primary Key in oracle

  JDBC Auto Increment Primary Key in oracle Create table SQL> create table stu50      ( sid number(10) primary key,        sname varchar2(15),         sadd  varchar2(15)      ); Create a sequence. SQL> create sequence sid_seq      start with 1 increment by 1; JDBC code:: ========= import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class OracleConn { private static final String query = "INSERT INTO STU50 VALUES(SID_SEQ.NEXTVAL,?,?)"; public static void main(String[] args) { try { //Connection Obj Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger"); PreparedStatement ps = con.prepareStatement(query); ps.setString(1, "smith"); ps.setString(2, "pune"); int count = ps.executeUpdate(); if(count!=0) { System.out.println("Record

Weather Observation Station 17 Hackerrank Solution - SQL

 Weather Observation Station 17 Hackerrank Solution - SQL for explanation watch video :: Code:: select round(long_w,4) from station where lat_n = (select min(lat_n) from station where lat_n>38.7780);

Weather Observation Station 16 Hackerrank Solution - SQL

 Weather Observation Station 16 Hackerrank Solution - SQL  For explanation watch video :: Code:: select round(min(lat_n),4) from station where lat_n>38.7780;