Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop
    1. Home
    2. akashmanujaya
    3. Best
    • Profile
    • Following 2
    • Followers 2
    • Topics 7
    • Posts 14
    • Best 8
    • Controversial 0
    • Groups 0

    Best posts made by akashmanujaya

    • I want to Enter my radio button value to the database in php

      I have tried t enter my radio button value to the database and in the console showing an error.
      I looked everywhere and tried everything to get the selected value from a group of radio buttons and i failed.
      Can anyone help me out.
      here is my code

      admin-map.php

      <?php
      include_once 'header.php';
      include_once 'locations_model.php';
      ?>
      
      
      <div id="map"></div>
      
      <!------ Include the above in your HEAD tag ---------->
      <script>
          var map;
          var marker;
          var infowindow;
          var red_icon =  'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
          var purple_icon =  'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
          var locations = <?php get_all_locations() ?>;
      
          function initMap() {
              var france = {lat: 6.8602, lng: 80.0535};
              infowindow = new google.maps.InfoWindow();
              map = new google.maps.Map(document.getElementById('map'), {
                  center: france,
                  zoom: 7
              });
      
      
              var i ; var confirmed = 0;
              for (i = 0; i < locations.length; i++) {
      
                  marker = new google.maps.Marker({
                      position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                      map: map,
                      icon :   locations[i][5] === '1' ?  red_icon  : purple_icon,
                      html: document.getElementById('form')
                  });
      
                  google.maps.event.addListener(marker, 'click', (function(marker, i) {
                      return function() {
                          confirmed =  locations[i][5] === '1' ?  'checked'  :  0;
                          $("#confirmed").prop(confirmed,locations[i][5]);
                          $("#id").val(locations[i][0]);
                          $("#description").val(locations[i][3]);
                          $("#image").attr("src", locations[i][4]);;
                          $("#form").show();
                          infowindow.setContent(marker.html);
                          infowindow.open(map, marker);
                      }
                  })(marker, i));
              }
          }
      
          function saveData() {
              var confirmed = document.getElementById('confirmed').checked ? 1 : 0;
              var id = document.getElementById('id').value;
              var Condition=document.getElementById('Condition').value;
      
              var fd = new FormData();
      
              fd.append('confirmed', confirmed);
              fd.append('id', id);
              // fd.append('Condition',Condition);
      
              $.ajax({
                  url : 'confirm_location.php',
                  type : 'POST',
                  data : fd,
                  processData: false,
                  contentType: false,
                  async: false,
                  success : function(data) {              
                      alert(data);
      
                      if(data == "Location added.")
                      {
                          infowindow.close();
                          window.location.reload(true);
                          return;
                      }
      
                      infowindow.setContent("<div style='color: purple; font-size: 25px;'>Inserting Errors</div>");
                      
                  },
                  error : function(request,error)
                  {
                      alert(error);
                  }
              });
          }
      
      
          function downloadUrl(url, callback) {
              var request = window.ActiveXObject ?
                  new ActiveXObject('Microsoft.XMLHTTP') :
                  new XMLHttpRequest;
      
              request.onreadystatechange = function() {
                  if (request.readyState == 1) {
                      callback(request.responseText, request.status);
                  }
              };
      
              request.open('GET', url, true);
              request.send(null);
          }
      
      
      </script>
      
      <div style="display: none" id="form">
          <table class="map1">
              <tr>
                  <image id="image" src="" style="width: 250px; height: auto;">
                  <input name="id" type='hidden' id='id'/>
                  <td><a>Description:</a></td>
                  <td><textarea disabled id='description' placeholder='Description'></textarea></td>
              </tr>
              <tr>
                  <td><b>Confirm Location ?:</b></td>
                  <td><input id='confirmed' type='checkbox' name='confirmed'></td>
              </tr>
              <tr>
                  <td><b>Set Condition</b></td>
                  <td><input type="radio" name="Condition" value="1" >Normal</td>
                  <td><input type="radio" name="Condition" value="2" >Bad </td>
                  <td><input type="radio" name="Condition" value="3">Very Bad</td><input>
              </tr>
      
              <tr><td></td><td><input type='button' value='Save' name="submit_btn" onclick='saveData()'/></td></tr>
          </table>
      </div>
      <script async defer
              src="https://maps.googleapis.com/maps/api/js?language=en&key=AIzaSyA-AB-9XZd-iQby-bNLYPFyb0pR2Qw3orw&callback=initMap">
      </script>
      
      
      

      confirm_location.php

      <?php
      
      if(isset($_POST['confirmed']) && isset($_POST['id']))
      {
      	$con=mysqli_connect ("localhost", 'root', '','demo');
      
      	if (!$con) {
      	    die('Not connected : ' . mysqli_connect_error());
      	}
      
      	$id = mysqli_real_escape_string($con, $_POST['id']);
      	$confirmed = mysqli_real_escape_string($con, $_POST['confirmed']);
      	$Condition = mysqli_real_escape_string($con,$_POST['Condition']);
      
      	// update location with confirm if admin confirm.
      	$query = "update locations set location_status = $confirmed WHERE id = $id ";
      	$query_condition="UPDATE locations set locationCondition = $Condition where id=$id";
      
      	$result = mysqli_query($con,$query);
      	// $result2=mysqli_query($con,$query_condition);
      
      	if ($result) {
      	    echo 'Location added.';
      	    return;
      	}
      
      	echo 'Can\'t add location';
      }
      else
      {
      	echo 'Please enter required fields';
      }
      
      
      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • How to Redirect to a unique jsp (using jsp id) file by using servlet

      I am going to crate a forum by using jsp and servlets. first of all i created a forum layout and i passed relevant question data to that layout when someone click a question. when you go to the ComapnyForum.jsp page you are able to post your answer. after you click the post button, form action goes to the PostAnswer servlet and it will send data to the database. what i want is, after you click the post button, reload the page ans show the answer that enterd before .i use

      <a href="CompanyForum.jsp?id=<%=rs.getString("id")%>" >
      

      in my jsp page and it worked very well. but when i used

      RequestDispatcher requestDispatcher = request.getRequestDispatcher("CompanyDashboard.jsp?id=<%=rs.getString("id")%>");
      requestDispatcher.forward(request, response);
      

      in my PostAnswer servlet, it is not working. please show me how to do this

      here is my CompanyForum.jsp

      <%
                     java.sql.Connection connection = null;
      
      
                      try
                      {
                          int id = Integer.valueOf(request.getParameter("id"));
                          connection = Connector.ConnectDb();
                          PreparedStatement pst = connection.prepareStatement(" SELECT * FROM question where id = '"+id+"' ");
                          ResultSet rs = pst.executeQuery();
                          while(rs.next())
                          {
                              String title=rs.getString("title");
                              String tags = rs.getString("tags");
                              String question = rs.getString("question");
                              int qid = rs.getInt("id");
                              request.setAttribute("tags", tags);
                              request.setAttribute("title", title);
                              request.setAttribute("question", question);
                              session.setAttribute("qid", qid);
                          }
                      } 
      
                      catch (SQLException ex) {
      
                      }
                  %>
                  <form class="margin-top-40" action="PostAnswer" method="post">
                  <div class="form-group">
                      <input type="text" placeholder="Place your title here" disabled style="color: rgba(1, 203, 225, 0.8); font-size: 20px; font-weight: bold" class="form-control" style="font-weight: bold;font-size: 20px;"  name="title" value='${title}'>
                  </div>
                    <div class="form-group">
                        <label style="color: #ffffff">Tags</label>
                        <input type="text" placeholder="Place your tags here" disabled class="form-control"  name="keywords" value='${tags}' style="color: rgba(1, 203, 225, 0.8);">
                        <input type="hidden" display="none" name="qid" value='${qid}' style="color: rgba(1, 203, 225, 0.8);">
      
                  </div>
                  <div class="form-group">
                    <label style="color: #ffffff;">Question Detials</label>
                    <textarea cols="12" rows="12" placeholder="Post Your Question Details Here....." name="message" class="form-control" style="color: #ffffff;" disabled=""> ${question} </textarea>
                  </div>
                   <div class="form-group">
                    <label style="color: #ffffff">Image</label>
                    <input class="input--style-4" type="file" name="image">
                  </div> 
      
      
                    <div class="form-group">
                    <label style="color: #ffffff">Answer</label>
                    <textarea cols="12" rows="12" placeholder="Post Your Answer Here....."  name="comment" class="form-control"></textarea>
                  </div>
                  <button class="btn btn-primary pull-right" value="submit" type="submit"> Post </button> 
                 <!-- <button class="btn btn-primary pull-right" value="reset">Reset</button>-->
                 <br>
                  <br>
                  <br>
                  <br>
                  <hr style="border: 2px solid rgba(1, 203, 225, 0.8);">
      
                 <h2>Answers</h2>
      
                 <table align="left" cellpadding="10" cellspacing="10" border="0">
      
                <%                  
                      try
                      {
                          int id = Integer.valueOf(request.getParameter("id"));
                          connection = Connector.ConnectDb();
                          PreparedStatement pst = connection.prepareStatement(" SELECT * FROM comment where q_id = '"+id+"' order by id ");
                          ResultSet rs = pst.executeQuery();
                          while(rs.next())
                          {
                  %>
      
                  <tr>
      
                      <td><ul><li><%= rs.getString("comment") %></li></ul></td>
                  </tr>
                  <% 
                  }
      
                  } 
                  catch (Exception e) {
                  e.printStackTrace();
                  }
                  %>
                  </table>
      
      
      
                </form>
      

      this is my PostAnswer.java

      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
      
          String comment = request.getParameter("comment");
          PrintWriter out = response.getWriter();
          int id = Integer.parseInt(request.getParameter("qid"));
      
          try
          {
              connection = Connector.ConnectDb();
              PreparedStatement pst = connection.prepareStatement("INSERT INTO comment (comment,q_id) values (?,?)");
              pst.setString(1, comment);
              pst.setInt(2, id);
      
              int rs = pst.executeUpdate();
      
              if(rs>0)
              {
                  RequestDispatcher requestDispatcher = request.getRequestDispatcher("CompanyDashboard.jsp?id=<%=rs.getString("id")%>");
                  requestDispatcher.forward(request, response);
      
              }
          } 
      
          catch (SQLException ex) {
              Logger.getLogger(PostAnswer.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
      
      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • I want to change map icon as location condition

      I want to change my map icon as location condition (value of locationCondition in the database column) in my website. but it shows only ELSE part (purple icon) icon only. please help me out to make this possible.
      Here is my code
      collectingStaff.php

      <section id="Locations">
      				<div class="container">
      					<div class="row">
      						<div class="col-sm-12 text-center">
      							<h2 class="section_header">
      								Locations You have to Clean UP!
      						</div>
      					</div>
      					<div class="row columns_margin_bottom_20" style="height: 600px" id="map">
      							<!-- Add Google Map to the div-->
      							<script>
      
      
      								$(document).ready(function(){
      								// $('#locs').append('<div>hello</div>');
      
      						        /**
      						         * Create new map
      						         */
      						        var infowindow;
      						        var map;
      						        var red_icon =  'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
      						        var purple_icon =  'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
      						        var black_icon ='https://static.thenounproject.com/png/102874-200.png';
      						        var locations = <?php get_confirmed_locations() ?>;
      						        var myOptions = {
      						            zoom: 11,
      						            center: new google.maps.LatLng(6.8602, 80.0535),
      						            mapTypeId: 'roadmap'
      						        };
      						        map = new google.maps.Map(document.getElementById('map'), myOptions);
      
      						        /**
      						         * Global marker object that holds all markers.
      						         * @type {Object.<string, google.maps.LatLng>}
      						         */
      						        var markers = {};
      
      						        /**
      						         * Concatenates given lat and lng with an underscore and returns it.
      						         * This id will be used as a key of marker to cache the marker in markers object.
      						         * @param {!number} lat Latitude.
      						         * @param {!number} lng Longitude.
      						         * @return {string} Concatenated marker id.
      						         */
      						        var getMarkerUniqueId= function(lat, lng) {
      						            return lat + '_' + lng;
      						        };
      
      						        /**
      						         * Creates an instance of google.maps.LatLng by given lat and lng values and returns it.
      						         * This function can be useful for getting new coordinates quickly.
      						         * @param {!number} lat Latitude.
      						         * @param {!number} lng Longitude.
      						         * @return {google.maps.LatLng} An instance of google.maps.LatLng object
      						         */
      						        var getLatLng = function(lat, lng) {
      						            return new google.maps.LatLng(lat, lng);
      						        };
      
      						        /**
      						         * loop through (Mysql) dynamic locations to add markers to map.
      						         */
      						        var i ; var confirmed = 0;
      						        for (i = 0; i < locations.length; i++) {
      
      						        	
      
      						            marker = new google.maps.Marker({
      						                position: new google.maps.LatLng(locations[i][1], locations[i][2]),
      						                map: map,
      						                icon :   locations[i][6] === '3' ?  black_icon  : purple_icon,
      						                html: "<div>\n" +
      						                "<table class=\"map1\">\n" +
      						                "<tr>\n" +
      						                "<td><a>Description:</a></td>\n" +
      						                "<td><textarea disabled id='manual_description' placeholder='Description'>"+locations[i][3]+"</textarea></td></tr>\n" +
      						                 "<td><a>Image:</a></td>\n" +
      						                "<td><img src="+locations[i][4]+" style='width: 250px; height: auto;'></td></tr>\n" +
      						                "</table>\n" +
      						                "</div>"
      						            });
      
      								     //       // ajax call get data from server and append to the div
      								     //       $('#locs').append('\
      						       //      		<div class="row">\
      				    					// 		<div class="col-md-12" id="'+ locations[i][0] +'" style="-webkit-box-shadow: 0 4px 6px -6px #222;-moz-box-shadow: 0 4px 6px -6px #222;box-shadow: 0 4px 6px -6px #222;margin:0;">\
      					    				// 			<div style="display: table-cell;">\
      					    				// 				<img src="../'+ locations[i][4] +'" style="width: 100px; height: auto; margin-bottom:20px;margin-top:20px">\
      					    				// 			</div>\
      					    				// 			<div style="display: table-cell; vertical-align: top; padding-left: 10px;padding-top:20px">\
      													// 	<div style="word-wrap: break-word;font-size:14px">'+locations[i][3]+'</div>\
      													// </div>\
      				    					// 		</div>\
      				    					// 	</div>\
      						       //      	');
      								    
      
      
      						            
      
      
      									
      						            google.maps.event.addListener(marker, 'click', (function(marker, i) {
      						                return function() {
      						                    infowindow = new google.maps.InfoWindow();
      						                    confirmed =  locations[i][4] === '1' ?  'checked'  :  0;
      						                    $("#confirmed").prop(confirmed,locations[i][4]);
      						                    $("#id").val(locations[i][0]);
      						                    $("#description").val(locations[i][3]);
      						                    $("#image").val(locations[i][4]);
      						                    $("#form").show();
      						                    infowindow.setContent(marker.html);
      						                    infowindow.open(map, marker);
      
      						                    
      						                    //reseting highlight
      						         //            for (j = 0; j < locations.length; j++) {
      				           //          	 		$("#"+ locations[j][0]).css("background-color", "transparent");
      
      
      						         //            }
      
      						         //            $("#"+ locations[i][0]).css("background-color", "#ff0000");
      
      					          //           	 $('#locs').animate({
      											    //     scrollTop: $("#" + locations[i][0]).offset().top
      											    // }, 2000);
      
      						     //                $("#"+ locations[i][0]).click(function() {
      
      											//   	var x = window.scrollX, y = window.scrollY;
      											//   	elem.focus();
      											//   	window.scrollTo(x, y);
      											// });
      
      						       
      						                }
      						            })(marker, i));
      						        }
      						        });
      
      								// // Initialize and add the map
      								// function initMap() {
        								// 			// The location of Uluru
        								// 			var uluru = {lat: -25.344, lng: 131.036};
      
        								// 			// The map, centered at Uluru
        								// 			var map = new google.maps.Map(
            							// 										document.getElementById('map'), {zoom: 1, center: uluru}
      								// 				);
      
        								// 			// The marker, positioned at Uluru
        								// 			var marker = new google.maps.Marker({position: uluru, map: map});
      								// }
         							</script>
      
         							<!--Apply API key for Google Map-->
          						<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?language=en&key=AIzaSyCbNfrYitHIsUd-UOQmRw0cDs7Y76vswv4">
          						</script>
      
          					
      					</div>
      				</div>
      			</section>
      

      location_model.php

      <?php
      require("db.php");
      
      // Gets data from URL parameters.
      if(isset($_GET['add_location'])) {
          add_location();
      }
      if(isset($_GET['confirm_location'])) {
          confirm_location();
      }
      
      
      
      function add_location(){
          $con=mysqli_connect ("localhost", 'root', '','demo');
          if (!$con) {
              die('Not connected : ' . mysqli_connect_error());
          }
          $lat = $_GET['lat'];
          $lng = $_GET['lng'];
          $description =$_GET['description'];
          $image=$_GET['image'];
          // Inserts new row with place data.
          $query = sprintf("INSERT INTO locations " .
              " (id, lat, lng, description,image) " .
              " VALUES (NULL, '%s', '%s', '%s','%s');",
              mysqli_real_escape_string($con,$lat),
              mysqli_real_escape_string($con,$lng),
              mysqli_real_escape_string($con,$description),
              mysqli_real_escape_string($con,$image));
      
          $result = mysqli_query($con,$query);
          echo"Inserted Successfully";
          if (!$result) {
              die('Invalid query: ' . mysqli_error($con));
          }
      }
      function confirm_location(){
          $con=mysqli_connect ("localhost", 'root', '','demo');
          if (!$con) {
              die('Not connected : ' . mysqli_connect_error());
          }
          $id =$_GET['id'];
          $confirmed =$_GET['confirmed'];
          // update location with confirm if admin confirm.
          $query = "update locations set location_status = $confirmed WHERE id = $id ";
          $result = mysqli_query($con,$query);
          echo "Inserted Successfully";
          if (!$result) {
              die('Invalid query: ' . mysqli_error($con));
          }
      }
      
      //Gettin Confirmed Locatons
      function get_confirmed_locations()
      {
          $con=mysqli_connect ("localhost", 'root', '','demo');
          if (!$con) 
          {
              die('Not connected : ' . mysqli_connect_error());
          }
      
          // update location with location_status if admin location_status.
          $sqldata = mysqli_query($con,"select id ,lat,lng,description,image,location_status as isconfirmed,locationCondition from locations WHERE  location_status = 1
        ");
      
          $rows = array();
      
          while($r = mysqli_fetch_assoc($sqldata)) {
              $rows[] = $r;
      
          }
      
          $indexed = array_map('array_values', $rows);
          //  $array = array_filter($indexed);
      
          echo json_encode($indexed);
          if (!$rows) {
              return null;
          }
      }
      
      
      function get_all_locations(){
          $con=mysqli_connect ("localhost", 'root', '','demo');
          if (!$con) {
              die('Not connected : ' . mysqli_connect_error());
          }
          // update location with location_status if admin location_status.
          $sqldata = mysqli_query($con,"
      select id ,lat,lng,description,image,location_status as isconfirmed
      from locations
        ");
      
          $rows = array();
          while($r = mysqli_fetch_assoc($sqldata)) {
              $rows[] = $r;
      
          }
        $indexed = array_map('array_values', $rows);
        //  $array = array_filter($indexed);
      
          echo json_encode($indexed);
          if (!$rows) {
              return null;
          }
      }
      function array_flatten($array) {
          if (!is_array($array)) {
              return FALSE;
          }
          $result = array();
          foreach ($array as $key => $value) {
              if (is_array($value)) {
                  $result = array_merge($result, array_flatten($value));
              }
              else {
                  $result[$key] = $value;
              }
          }
          return $result;
      }
      
      ?>
      
      
      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • RE: How to Redirect to a unique jsp (using jsp id) file by using servlet

      @akashmanujaya founded!!!

      RequestDispatcher requestDispatcher = request.getRequestDispatcher("CompanyForum.jsp?id=" + id);
      requestDispatcher.forward(request, response);
      
      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • How to update a table withing a User defined Function in SQL SERVER

      Since I am new to sql server, I want to update Flight_shedule_date where the value of Flight_number witch is come from the @delay_info virtual table. Here what i have done. Please help me out

      CREATE FUNCTION delayInfo (@status varchar(50),@date date)
      
      RETURNS @delay_info TABLE 
      	(
      		Status varchar (50),
      		Remark varchar (50),
      		Arrival_teminal_number char (8),
      		Staff_ID char (5),
      		Leg_number char (10),
      		Flight_number char(5),
      		Passport_number char(10),
      		Passenger_name varchar(50),
      		Passenger_catogary varchar(30),
      		Passenger_Requirement varchar (50)
      		
      	)
      
      AS
      	BEGIN
      		
      		INSERT INTO @delay_info (Status,Remark,Arrival_teminal_number,Staff_ID,Leg_number,Flight_number,Passport_number,Passenger_name,Passenger_catogary,Passenger_Requirement)
      
      		SELECT Flight_leg_B.Status,Flight_leg_B.Remark,Flight_leg_B.Arrival_teminal_number,Flight_leg_A.Staff_ID,Flight_leg_A.Leg_number,Flight_leg_A.Flight_number,Passenger_A.Passport_number,Passenger_A.First_name+Passenger_A.Minit+Passenger_A.Last_name as Name, Passenger_catogary.Passenger_catogary,Passenger_requirements.Requirement
      		from Flight_leg_B 
      		JOIN  Flight_leg_A on (Flight_leg_B.Arrival_teminal_number=Flight_leg_A.Arrival_teminal_number)
      		JOIN  Aircrew on (Flight_leg_A.Staff_ID=Aircrew.Staff_ID)
      		JOIN Passenger_A on (Flight_leg_A.Leg_number=Passenger_A.Leg_number)
      		JOin Passenger_catogary on (Passenger_A.Passport_number=Passenger_catogary.Passport_number)
      		JOIN Passenger_requirements on (Passenger_A.Passport_number=Passenger_requirements.Passport_number)
      
      		Where Status=@status
      
      		Declare @FlightNumber char(5) =  'select Flight_number from @delay_info '
      		
      		Update Flight_shedule_date set Date=@date where Flight_number=@FlightNumber
      
      		Print 'Flight Shedule date Updated'
      		
      			
      
      		RETURN
      		END
      
      

      When i execute the query it will show this error:
      Msg 443, Level 16, State 15, Procedure delayInfo, Line 35 [Batch Start Line 0]
      Invalid use of a side-effecting operator 'UPDATE' within a function.
      Msg 443, Level 16, State 14, Procedure delayInfo, Line 37 [Batch Start Line 0]
      Invalid use of a side-effecting operator 'PRINT' within a function.

      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • How to redirect to a jsp page from a servlet by using Database values

      well I have a jsp page with a login form, i'm using a servlet, if the email and password are correct the servlet redirects the user to another page else it redirects him to the login page again with alert.

      when i log in with a correct email and password i'm redirected perfectly to index.jsp
      but when i put a wrong email or password in the form when i click on the submit button the page redirecting to the index.jsp. How can i sort out this

      here is the servlet

      package Company;
      
      import java.io.IOException;
      import java.io.PrintWriter;
      import java.sql.*;
      
      import javax.servlet.ServletException;
      import javax.servlet.annotation.WebServlet;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import javax.servlet.http.HttpSession;
      
      /**
       * Servlet implementation class LogServlet
       */
      @WebServlet("/LogServlet")
      public class CompanyLoginServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
      
      
      
      
      public CompanyLoginServlet() {
          super();
      
      }
      
      
      
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          response.setContentType("text/html");
      
      
          String email=request.getParameter("email");
          String password=request.getParameter("pass");
      
          PreparedStatement ps = null;
          ResultSet rs = null;
      
          try {
              Class.forName("com.mysql.jdbc.Driver");
              Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/javaee?useSSL=true", "root", "");
              ps = (PreparedStatement) conn.prepareStatement("select emp_Email,Emp_Password from employer where emp_Email = ? and Emp_Password = ?");
      
              ps.setString(1, email);
              ps.setString(2, password);
              rs=ps.executeQuery();
      
      
      
          try {
              while(rs.next()){
              if(email.equals(rs.getString(3)) && password.equals(rs.getString(4))){
                  response.sendRedirect("../../Company/index/index.jsp");
              }
              else{
                  response.sendRedirect("CompanyLogin.jsp");
      
              }}
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
      
          }
          System.out.close();
      
      
          }
          catch(Exception e){e.printStackTrace();}
      
      
      }
      }
      

      here is my JSP

      <%-- 
          Document   : CompanyLogin.jsp
          Created on : Feb 24, 2019, 9:42:17 PM
          Author     : Akash
      --%>
      
      <%@page import="java.sql.Statement"%>
      <%@page import="java.sql.Connection"%>
      <%@page import="java.sql.ResultSet"%>
      <%@page contentType="text/html" pageEncoding="UTF-8"%>
      <!DOCTYPE html>
      <html lang="en">
      <head>
      	<title>Login V18</title>
      	<meta charset="UTF-8">
      	<meta name="viewport" content="width=device-width, initial-scale=1">
      <!--===============================================================================================-->	
      	<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
      <!--===============================================================================================-->	
      	<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
      <!--===============================================================================================-->	
      	<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
      <!--===============================================================================================-->
      	<link rel="stylesheet" type="text/css" href="css/util.css">
      	<link rel="stylesheet" type="text/css" href="css/main.css">
      <!--===============================================================================================-->
      </head>
      <body style="background-color: #666666;">
      	
          <div class="limiter">
      	<div class="container-login100">
                  <div class="wrap-login100">
                      <form class="login100-form validate-form" method="POST" action="../../Company/index/index.jsp ">
                          <span class="login100-form-title p-b-43">
      			Login to continue
                          </span>
      					
      					
                          <div class="wrap-input100 validate-input" data-validate = "Valid email is required: [email protected]">
      			<input class="input100" type="text" name="email">
                              <span class="focus-input100"></span>
                              <span class="label-input100">Email</span>
                          </div>
      					
      					
                          <div class="wrap-input100 validate-input" data-validate="Password is required">
      			<input class="input100" type="password" name="pass">
      			<span class="focus-input100"></span>
                              <span class="label-input100">Password</span>
                          </div>
      
                          <div class="flex-sb-m w-full p-t-3 p-b-32">
      			<div class="contact100-form-checkbox">
                                  <input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
                                  <label class="label-checkbox100" for="ckb1">
      				Remember me
                                  </label>
      			</div>
      
      			<div>
                                  <a href="#" class="txt1">
      				Forgot Password?
                                  </a>
      			</div>
                          </div>
      			
      
                          <div class="container-login100-form-btn">
      			<button class="login100-form-btn">
                                  Login
      			</button>
                          </div>
      		</form>
      
      		<div class="login100-more" style="background-image: url('images/bg-01.jpg');">
      		</div>
                  </div>
      	</div>
          </div>
          
      
      	
      
      	
      	
      <!--===============================================================================================-->
      	<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
      <!--===============================================================================================-->
      	<script src="vendor/animsition/js/animsition.min.js"></script>
      <!--===============================================================================================-->
      	<script src="vendor/bootstrap/js/popper.js"></script>
      	<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
      <!--===============================================================================================-->
      	<script src="vendor/select2/select2.min.js"></script>
      <!--===============================================================================================-->
      	<script src="vendor/daterangepicker/moment.min.js"></script>
      	<script src="vendor/daterangepicker/daterangepicker.js"></script>
      <!--===============================================================================================-->
      	<script src="vendor/countdowntime/countdowntime.js"></script>
      <!--===============================================================================================-->
      	<script src="js/main.js"></script>
      
      </body>
      </html>
      
      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • RE: I want to Enter my radio button value to the database in php

      @dev_lak Thankx A lot

      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • RE: I want to change map icon as location condition

      @dev_lak It worked perfectly .. Thankz for your massive help :v: :kissing:

      posted in Back-End Development
      akashmanujaya
      akashmanujaya
    • 1 / 1