JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.

Hi Team,
 
I build a page where one drop down is there in drop down all weeks days are coming while selecting the date all days only enable in date picker . suppose we select Monday from drop down then in date picker  only all Mondays are enable to select other days are disable .

now my requirement is that in place of days we select month from drop down then only that particular month is enable on date picker other months are disable to select .


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet"
	href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function ()
	    {
	        //datepicker
	        $("#txtstart_date").datepicker
	        ({
	            minDate:"dateToday",
	            dateFormat: 'dd-mm-yy',
	            changeMonth: true,
	            numberOfMonths: 1,
	            onClose: function (selectedDate) {
	                $("#txtend_date").datepicker("option", "minDate", selectedDate);
	            },
	            //Code to disable dates according to selection
	            beforeShowDay: filterDate
	        });
	    });
	    //By default no day selected in dropdown. So all the days will be 

Open in new window

0
I m sending an ajax call in below method after return the success message i want to clear the form in same page so form also get cleared and success
 message also print in jsp page please help me out on this thanx a ton in advance.
 
 
 
 $(document).ready(function() {
	$("#data").click(function(evt) {
		evt.preventDefault();
		 if(save()){
			$.ajax({
				url: "Test.jsp",
				type: "post",
				data: {
				pS:$('#pS').val(),
				pType:$('#pType').val(),
				pCode:$('#pCode').val(),
				mYear:$('#mYear').val(),
				pDate:$('#pdate').val(),
				ppDate:$('#ppdate').val(),
				bDate:$('#bdate').val()},
				success: function(responseFromServer) {
	            	$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {	
	                    $('#content').html(resultMessageKey);
	                });
	             },
	            error: function() {
	                alert(" Ajax call Failed to Update Values into Database");
	            }
			});
		 }
		 else
			 {
			 
			 }
	});
});

Open in new window

0
I need to add a spinner to this button. I've been given som CSS to do it but I'm not sure what is going on since its not working. How do I attach this spinner css to my button to make it work? I'm also open to any other options for attaching a spinner . Thanks in advance.

                                        <div class="col-md-1 checkinItem">
                                            <button
                                                id="btnBarcodeLookup"
                                                class="SearchButtonV2"
                                                runat="server"
                                                onserverclick="btnBarcodeLookup_OnClick"
                                                validationgroup="barcodestatus">
                                            </button>
                                        </div>

Open in new window


.Spinner {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: absolute;
  border: 5px solid #eee;
  display: inline-block;
  
  // Positioning
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  
  &:after, &:before {
    content: '';
    display: block;
    width: 100px;
    height: 100px;
    border-radius: 50%;
  }
  
  &:after {
    position: absolute;
    top: -5px;
    left: -5px;
    border: 5px solid transparent;
    border-top-color: #928a8a;
    animation: spin 1s linear infinite;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  
  100% {
    transform: rotate(360deg);
  }
}

Open in new window

0
Hi I have a jsp page  where 2 drop downs are there we have to select and then submit the data
it will goes to a servlet after implementing the business logic servlet return the same page
with dispatcher.forward(request, response) function. i want to retain the 2 drop down values
and auto selected while servlet send response back to jsp . hope this clears my requirement
please let me know if any queries.
0
i have 3 fields in tabular formate like below

<tr>
    <th>Check/UnCheck</th>
      <th>MYear</th>
      <th>P Date</th>
      <th>Q Date</th>
      <th>B Date</th>
  </tr>
  <tr>
    <td align="top">
      <input type="checkbox" class="chkValues" id="ckbCheckAll" name="chkBox" type="checkbox" data-row="1" value="" size="50">
    </td>
    <td align="left">
      <input class="inputText row1" type="text" name="mYear" id="mYear"  value="2020">
    </td>
    <td>
      <input class="date row1" id="pDate1" name="dob" type="date" value="2020-01-01" />
    </td>
    <td>
      <input class="date row1" id="qDate1" name="dob" type="date" value="2020-01-01" />
    </td>
    <td>
      <input class="date row1" id="bDate1" name="dob" type="date" value="2020-01-01" />
    </td>
  </tr> 
  <tr>
    <td align="top">
      <input type="checkbox" class="chkValues" id="ckbCheckAll" name="chkBox" type="checkbox" data-row="2" value="" size="50">
    </td>
    <td align="left">
      <input class="inputText row2" type="text" name="mYear" id="mYear"  value="2020">
    </td>
    <td>
      <input class="date row2" id="pDate2" name="dob" type="date" value="2020-02-01" />
    </td>
    <td>
      <input class="date row2" id="qDate2" name="dob" type="date" value="2020-02-01" />
    </td>
    <td>
      <input class="date row2" id="bDate2" name="dob" type="date" value="2020-02-01" />
    </td>
  </tr> 
</table>  

Open in new window




1 ) i want to do first date filed (pDate1) when click in date picker from system date + 7 days are only enable to pick all past date are not enable to pick in date picker
2 ) in second field (qDate1) only after pDate1 is enable to pick in date picker
3 ) in second field (bDate1) only after qDate1 is enable to pick in date picker

please let me know if i want to describe more .
0
how can i send ajax call to database and retrieve a table having 5 columns data as json  and render in jsp to display .
0
How can i reload the page with success message when ajax response will get from java controller .
Case - i am sending an ajax request to java controller it is successfully going to java controller i am setting a response in controller and revert it back to jsp . while success i want to reload the page with success message which i already set in java controller.
0
Requirement Description Imagehow can i send dynamically created fields through ajax to servlet?

i have a jsp page where i fetch data from a table and display there are 3 date fields

all row having checkbox when i click on chekbox new date value should go to servlet through ajax.
code are below -

<table align=center>

<tr>			<th>Check/UnCheck</th>
                <th>MYear</th>
                <th>Date1</th>
                <th>Date2</th>
                <th>Date3</th>
</tr>
<%for(int i=0 ; i<mYearVector.size();i++)
{
	
%>
 <tr>
<td align="top">
<INPUT type="checkbox" class="chkValues" id="ckbCheckAll" name="chkBox" type="checkbox" value="" size="50">
</td>
<td align="left">
<input class=inputText type="text" name="mYear" id="mYear"  value="<%=mYearVector.elementAt(i)%>"  readonly>
</td>

				<td>
		            <input class="date1" id="payrollCutOffDate<%=i%>" name="dob" type="text" value="<%=(oldValues.elementAt(0)==null?"":oldValues.elementAt(0))%>" />
				</td>
				<td>
		            <input class="date2" id="payrollPaymentDate<%=i%>" name="dob" type="text" value="<%=(oldValues.elementAt(1)==null?"":oldValues.elementAt(1))%>" />
				</td>
				<td>
		            <input class="date3" id="inactiveDate<%=i%>" name="dob" type="text" value="<%=(oldValues.elementAt(2)==null?"":oldValues.elementAt(2))%>" />
				</td>
</tr> 
<%}%>

</table>

Open in new window

0
Hi ,
I have a grid view in jsp where 3 date fields are. The data is coming from a database. Each and every row there is a checkbox. when checkbox is checked all 3 dates fields having datepicker. we can update the date and on submit it should go on other jsp where backend logic is there which updates the field in database.

please send me some code snippet examples of how I can do this in JavaScript.
0
Hi i have a table having 8 columns i want to retrieve data from database and show in jsp page tabular form. after that implement edit , insert and delete in particular row or multiple row simultaneously . please provide a possible code sample as well as.
0
How can i enabled checkbox while loaing the page . ,row are coming from database when i am using below function -

$(document).ready(function() {
	var checkboxes = $( ':inputtext' ),
		checkboxes.prop( 'checked', true );
});

Open in new window



it runs on load but value are coming from database after that that why above was't work
1
how can i show and hide one table based on a button click in jsp page.
0
i have button and a i-frame in my jsp page but i want to show that i-frame button while click on that button . when i click on button i-frame content should visible
else hide.
1
want to fetch 2 columns data from jsp into vector suppose id and name .
after that want to display on same jsp 1 checkbox added in front of each row
while checking the checkbox  send id as checkbox parameter to servlet.
0
when i m generating .xlsx file it's genrating perfectly but every time some header name is missing .
suppose 20 column is there in a xlsx file some time 1or 2 or 3 header name was missing .
data are coming but only header name is missing there please let me know what is the issue.
0
hi am geting the following error

Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.20
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          May 3 2019 22:26:00 UTC
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.20.0
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Java\jdk1.8.0_111\jre
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_111-b14
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\Desmond\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Sep 09, 2019 8:31:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Program Files\Apache Software …
0
i have a code below where i am traversing a list in jsp containing employee_id and employee_name
<tr>
                                                <td align="top"><INPUT class="inputtext" name="chkBox" type="checkbox" value="<%=employee.get(0)%>" size="50"></td>
                                                <td><label><%=employee.get(0)%></label></td>
                                                <td><label><%=employee.get(1)%></label></td>
</tr>

along with each and every row there is a checkbox when i am selcting chekboxes and click on submit button presently on employee_id (value="<%=employee.get(0)%>") is going along with
checkbox value i want both employee_id and employee_name will go with checkbox value to servlet . in servlet there is a query run and employee_id and
employee_name should be entered into specific table. please help me out on this .please let me know if not clear.
0
HI Team ,

I am retrieving value from database through JDBC statement  my plsql query is below -

Select * from A union Select * from B.

but when i am retrieving value through JDBC statements its give null . when i am individually running query like Select * from A without using Union  its working fine and giving results but when i am using 2 query via Union its give Null. Please tell me where i m wrong .
0
Hi Team, my popup code is below please let me know how to do pagination on popup window.

<script>
		jQuery(function($) {
		   $(".openPopup").on("click", function(event) {
			   event.preventDefault();
			   $("#myModal").show();
			   $("#divForCSSPopup").load("/path/to/your/page.jsp body", function() {
				   $("form", "#divForCSSPopup").submit(function(event) {
					   event.preventDefault();
					   var listOfCheckbox = [];
					   var trs = ["<tr><td>ID</td><td>NAME</td></tr>"];
					   $(":checkbox", this).each(function() {
						   // your checkbox must be like
						   // <input type="checkbox" data-id="123" data-name="someName" value="456" />
                           trs.push("<tr><td>" + $(this).data("id") + "</td><td>" + $(this).data("name") + "</td></tr>");
						   listOfCheckbox.push({employeeID: $(this).data("id"), employeeName: $(this).data("name")})
					   });
					   // checking
					   alert(JSON.stringify(listOfCheckbox));
                       $("#putMyEmployeeInfosHere").html( "<table>" + trs.join("") + "</table>" );
					   $("#myModal").hide();
				   });
			   });
		   });
		});
	</script>

Open in new window



please let me know solution asap.
0
How can i refresh a div only once i got a response from popup.my scenario is below -

i have a Parent JSP page . in parent.jsp page there is a button which opens a popup when popup is open it fetch the table data from database . table data contains Employee_ID, Employee_Name . in popup jsp when displaying data each and every row contains a checkbox . after multiple selection of checkbox there is a submit button in popup.jsp , after submitting the page comes back to the parent.jsp page and display the popup.jsp submitted Emplyee_ID and Employee_Name.

my problem is when i m getting response back from popup.jsp to parent.jsp file my specific table is not refreshing , when i am debugging parent.jsp , list are coming with data but not displaying because it is not refresh at the moment when response are coming back from popup.jsp t parent.jsp .

Please let me know the solution.
0
Hi Team ,

i have a problem but i did't get any solution for it . i have a parent jsp from where a search icon is there when i click on search icon a popup jsp is open . in popup jsp i retrieve values form database and display.
there is 2 column in database Employee_ID and Employee_Name. all values come row by row and display on popup jsp . in each row there is a checkbox no my problem comes and i did't get any solution for it please help me out.there is two case -

1 Case - when i check multiple check boxes in popup.jsp and click on submit button(popup.jsp) the value of Employee_ID and Employee_Name   should display on parent.jsp.

2 Case - when i check multiple check boxes in popup.jsp and click on submit button(popup.jsp) the value of Employee_ID and Employee_Name should go to a servlet and after that servlet send that data to parent.jsp.


please let me know both of the above solutions.
0
I am using datetimepicker.js to enter dates, my problem is the pop up seems to be positioned by screen position rather than window position and in chrome pops up behind the window not on top...

My Configured variables

;
var WeekDayName1=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var WeekDayName2=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
var exDateTime;//Existing Date and Time
var selDate;//selected date. version 1.7


//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="Date Picker";//Date Time Picker title.
var WeekChar=3;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="/";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24

var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var 

Open in new window

1
I added a new value to my  home.jsp - jobtitle.
I added a new private string to my class containing jobtitle with setters and getters
I added the jobtitle to my impl: aContact.setJobTitle(rs.getString("jobtitle"));

the home.jsp is returning a 500 error.

HTTP Status 500 – Internal Server Error
Type Exception Report

Message An exception occurred processing JSP page [/WEB-INF/views/home.jsp] at line [28]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: An exception occurred processing JSP page [/WEB-INF/views/home.jsp] at line [28]

25:                     <tr>
26:                           <td>${status.index + 1}</td>
27:                               <td>${contact.name}</td>
28:                               <td>${contact.jobtitle}</td>
29:                               <td>${contact.email}</td>
30:                               <td>${contact.address}</td>
31:                               <td>${contact.telephone}</td>


Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:584)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
0
I created a  JSP page to upload files from this  example:
https://www.javacodegeeks.com/2013/08/file-upload-example-in-servlet-and-jsp.html

I followed this to the T and it comes back with this error message after I click on upload. I have enclosed the complete source int the ZIP with the pom file

Here is the error:

HTTP Status 500 – Internal Server Error
Type Exception Report

Message Error instantiating servlet class [FileUploadHandler]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Error instantiating servlet class [FileUploadHandler]
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      …
0
I tried jsp custom tag example.

custom tag color is not changing even though i changed to blue or some other color it still shows default color as attached.

Index.jsp is

<%--
    Document   : index
    Created on : Nov 6, 2018, 1:41:41 PM
    Author     : saiganesh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="mytags" uri="/WEB-INF/tlds/my_tags" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <mytags:formattag colour="blue" font_size="50" is_uppercase="false">
            this is ext hello custom tag
            </mytags:formattag>
    </body>
</html>



my_tags.tld is

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
  <tlib-version>1.0</tlib-version>
  <short-name>my_tags</short-name>
  <uri>/WEB-INF/tlds/my_tags</uri>
 
  <tag>
      <name>formattag</name>
      <tag-class>tags.FormatTag</tag-class>
      <body-content>scriptless</body-content>
      <attribute>
          <name>colour </name>
          <required>true</required>
      </attribute>
        <attribute>
          <name>font_size </name>
          <required>true</required>
      …
0

JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.