controller availablity in jsp
I am unable to access the secondcontroller and secondsercice in the Base.jsp or first.jsp.
But I am able to view the secondcontroller and secondsercice in the inspect elements.
if I observe ng-click in the insect elements <a href="javascript: void(0);" class="ng-binding"
.
If I execute second.jsp then the controller and service is working and getting the data in onload. when I use the below process I am not getting onload data. How can I make work the below process like second.jsp
Base.jsp
<%@include file="CacheBustUrl.jsp" %>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="myController.js" ></script>
</head>
<body ng-app="myApp"
ng-controller="myController">
<onload-documents-directive></onload-documents-directive>
<get-documents></get-documents>
</div>
<jsp:include page="first.jsp"></jsp:include>
</div>
</body>
</html>
first.jsp.
<%@include file="CacheBustUrl.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body onload-documents-directive>
<div class="modal fade rotate" id="firstPopup">
<div class="modal-dialog" style="width:1032px !important;">
<div class="modal-content">
<div class="container"></div>
<div class="modal-body">
<jsp:include page="second.jsp"></jsp:include>
</div>
</div>
</div>
</div>
</body>
</html>
second.jsp
<%@include file="CacheBustUrl.jsp"%>
<!doctype html>
<html>
<head>
<script src="${secondControllerjs}"></script>
<script src="${secondServicejs}"></script>
<script src="${cbemptyCheckerjs}"></script>
</head>
<body ng-app="myApp" onload-documents-directive
ng-controller="secondController"
ng-init="mySwitch=true" disable-keys>
</body>
</html>
See also questions close to this topic
-
Adding a constructor to an injected Project Class
I'm trying to add a constructor, which I call
ctor
, toProject
, so I can add to it some properties when it's instantiated.Here's the (absolutely ghastly) hack I'm using on
Item
to make this tick:const canvas = document.querySelector('canvas') paper.setup(canvas) paper.Item.inject({ ctor: function(args) { console.log('Item constructed!') } }) // All Items are supposed to call `_initialize` so we "hook" there. const Item_initialize = paper.Item.prototype._initialize const Item_ctor = paper.Item.prototype.ctor paper.Item.prototype._initialize = function(...args) { const initializer = Item_initialize.apply(this, args) if (Item_ctor) Item_ctor.apply(this) return initializer } const path = new paper.Path.Line({ strokeColor: 'black', strokeWidth: 5, from: 100, to: 50 })
<script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.12.0/paper-core.js"></script> <canvas></canvas>
Unfortunately the above trick doesn't work on
Project
:const canvas = document.querySelector('canvas') paper.setup(canvas) paper.Project.inject({ ctor: function(args) { // Not called console.log('Project constructed!') } }) const Project_initialize = paper.Project.prototype._initialize const Project_ctor = paper.Project.prototype.ctor paper.Project.prototype._initialize = function(...args) { const initializer = Project_initialize.apply(this, args) if (Project_ctor) Project_ctor.apply(this) return initializer } const project = new paper.Project(canvas)
<script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.12.0/paper-core.js"></script> <canvas></canvas>
What am I missing here?
-
How to delete div and all element inside div? Javascript, html, css
I have a function that clears the entire div and it disappears but still appears in the inspect (html). This is a real problem because we have this input type field on the email and I got this empty data in email. I only want when this value is not chosen to completely remove me from html and inspect. Look at my code and try to catch the error. The most important things in the whole code that you need to pay attention are
onchange="checkSelected()"
in html and first script tag which manipulate with that. It should simply become a display none but it still stands there.<div class="modal fade" id="montageModal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content" style="display: flex;"> <div class="modal-body"> <form id="schedule_form" class="clearfix" action="index.php?route=api/reifenmontage" method="post"> <div class="container-fluid"> <div class="step_1" > <h3 class="modal-title">Reifenmontage Termin buchen </h3> <div class="row termin_row"> <div class="col-xs-12 col-sm-4"> <div class="row"> <label>Pneu-Typ</label> </div> </div> <div class="col-xs-12 col-sm-6"> <div class="row"> <select onchange="checkSelected()" class="form-control" name="pneu" id="pneu"> <option value="Motorrad">Motorrad</option> <option value="Auto">Auto</option> </select> </div> </div> </div> <div id="additionalRow" class="row termin_row" > <div id="reifenmontage-input" class="row termin_row"> <div class="col-xs-12 col-sm-4"> <div class="row"> <label>Mark und model</label> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="row"> <select name="marka" class="form-control" id="button-getdata"> </select> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="row"> <select name="model" class="form-control" id="result" > </select> </div> </div> </div> </div> <div class="row termin_row"> <div class="col-sm-4 col-xs-12"> <div class="row"><label>2. Terminvorschlag</label></div> </div> <div class="col-sm-4 col-xs-6"> <div class="row"> <div class="input-group date" id="date-2" data-termin="1"> <input type='text' class="form-control" name="date[1]" /> <span class="input-group-addon">um</span> </div> </div> </div> <div class="col-sm-4 col-xs-6"> <div class="row"> <div class="input-group time" id="time-2" data-termin="1"> <input type='text' class="form-control" name="time[1]" /> <span class="input-group-addon">Uhr</span> </div> </div> </div> </div> <div class="row"> <div class="checkbox"> <label> <input type="checkbox" name="accept" id="accept"> Ich akzeptiere die <a href="teilnahmebedingungen" target="_blank">Teilnahmebedingungen</a> </label> </div> </div> <div class="row text-center"> <button type="button" class="btn btn-primary btn-lg btn-submit" id="next_step" disabled="disabled">Anfrage senden</button> </div> </div> <div class="step_2"> <h3 class="modal-title">Your contact info</h3> <div class=""> <div class="form-group clearfix"> <input type="text" name="name" value="<?= $user['name'] ?>" placeholder="Name and Lastname" class="form-control name text" required /> </div> <div class="form-group clearfix"> <input type="text" name="phone" value="<?= $user['phone'] ?>" placeholder="Phone" class="form-control phone text" required /> </div> <div class="form-group clearfix"> <input type="email" name="email" value="<?= $user['email'] ?>" placeholder="Email" class="form-control email text" required /> </div> <div class="text-center"> <button type="submit" id="submit" class="btn btn-default btn-lg btn-submit" >Suchen</button> </div> </div> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">SCHLIESSEN</button> </div> </div> </div> </div>
and my script tag
<script type="text/javascript"> let selectItem = document.getElementById('pneu'); let additionalRow = document.getElementById('additionalRow'); function checkSelected() { if (selectItem.selectedIndex == "1") { additionalRow.style.display = 'none'; } else { additionalRow.style.display = 'block'; } } </script> <script type="text/javascript"> $('#button-getdata').on('change', function() { $.ajax({ url: 'index.php?route=api/reifenmontage/get_marka_data', type: 'post', data: $('#reifenmontage-input select'), dataType: 'json', beforeSend: function() { }, success: function(json) { if (json['success']) { $("#result").empty(); for (i in json['success']) { var element = json['success'][i]; var o = new Option(element['model'], element['model']); $("#result").append(o); html = "\t<option value=\""+ element['model'] + "\">" + element['model'] + "</option>\n"; $("#result").append(o); } // document.getElementById("schedule_form").reset(); } } }); }); </script> <script type="text/javascript"> $.ajax({ url: 'index.php?route=api/reifenmontage/mark', context: document.body, success: function(data) { const selectControl = $('#button-getdata'); selectControl.html(data.map(ExtractData).join('')); } }); function ExtractData(item) { return ` <option value="${item.value}">${item.label}</option>`; } </script>
-
How to change the color of words in jumbotron using the reference $jumbotron?
I am learning web design and js .On my webpage, I define the default color is black in jumbotron h2.
.jumbotron h2{ text-align: center; color:black; }
define reference var $jumbotron = $('.jumbotron h2'); while running, I use
$jumbotron.html('hellow world'); ......
to display some words and I want to change its color but I do not know how to set new color while running, how to get the color value and assign a new value for my variable $jumbotron? I have tried$jumbotron.color =
or$jumbotron.color('')
but they are wrong. I have not found any useful answers with google. -
Can searchResponse.getHits().getHits(); throw nullpointer exception
We are getting a nullpointerexception at searchResponse.getHits().getHits(); I'm totally new to elastic search and don't know how it works but need to analyse this issue.
Let me know if it throws nullpointerexception in any case ? If it throws how to handle this ?
-
Is it possible to disable SSL certificate checking in the amazon kinesis consumer library v2?
When developing a Kinesis Consumer using Version 2 of the Kinesis Consumer Library and overriding the Dynamo DB endpoint to a localstack endpoint the library fails to create the leasing table due to SSL handshake errors.
I can confirm that creating the table succeeds when using AWS' Dynamo DB, but as soon as I override the endpoint url to a localstack url the Dynamo DB client fails to create the lease table after multiple retries. The stack trace isn't that useful but Wireshark shows all of the SSL handshake errors so I can only assume the Amazon SDK is not accepting the localstack certificate. I cannot find any mention of how to disable certificate verification using the
software.amazon.awssdk
package.Region region = Region.of("us-east-1"); DefaultCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create(); DynamoDbAsyncClient dynamoClient = DynamoDbAsyncClient.builder() .region(region) .endpointOverride(URI.create("https://localhost:4569")) .credentialsProvider(credentialsProvider) .build();
/edit This is based off the example from Amazon found here: https://docs.aws.amazon.com/streams/latest/dev/kcl2-standard-consumer-java-example.html
-
Problem creating an OracleDataSource correctly from tomcat context.xml
In the project im working at the following problem occurs:
We use Database connections defined in our tomcat context.xml. For now this has worked without problems.
Example:
<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver" logAbandoned="true" maxIdle="10" maxTotal="100" maxWaitMillis="5000" name="NAME" password="PASSWORD" removeAbandonedOnMaintenance="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" url="URL" username="USERNAME" />
This type of resource definition is used in the webapp for every database connection, retreiving the datasource like this:
InitialContext ctx = new InitialContext(); DataSource dsAux = (DataSource) ctx.lookup(dbCon);
The problem begins here. Oracle queues are being used with jms (Java Message System) for a lot of processes. For this, as it is coded right now, we need an OracleDataSource that can be created having only the db url, password and username.
My question is, is it possible in any way or form to get all the data needed from the context for this type of datasource correctly? I have tried changing the datasource type without any luck, unwrapping the already created datasource to try and create an OracleDataSource, in the end, the only possible solution I have come up with is to change how database connections are saved.
-
Why ng-repeat records multiply in combobox in Aspnet Mvc?
I am using angularjs ng-repeat for a combobox but it multiply records that n*n times.(if there is 5 record then it show 5*5=25 records)
I use ng-repeat like this:
<div class="profile-info-value userbase"> <select class="form-control" id="DepositorID" name="DepositorID" ng-model="SearchModel.DepositorID" sc-model="SearchModel.DepositorID" sc-nullable="1"> <option value="0"> </option> <option ng-repeat="item_ in SearchModelDepositorIDs" value="{{item_.DEPO_ID}}">{{item_.DEPO_DESCRIPTION}}</option> </select> </div>
and I fill SearchModelDepositorIDs like below:
$.post($scope.addressgetdepolist).done(function (Result) { if (Result.Success) { $scope['SearchModelDepositorIDs'] = Result.Data; $scope.$apply(); CloseWaiting(); }
I call this method once on formLoad.
As result returned 15 records and showed 225 records:
When debug I see list has 15 records but anyway ng-repeat multiply records.
Can you help me for this?
Edit: Result.Data:
-
Telerik Kendo Grid Rebind Issue
I am trying to filter the data from outside kendo grid. After getting right data, I am not able to see filtered data on UI.
$scope.kendogridOptions.dataSource.read(); - Not working out
Thanks in advance !
-
Behaviour of PHP API change when sending json data
I've a php script who manage the connection of a user. When the connection is accepted by the script, a JSON web token is sent to the web service. The problem is, when I test my connection API with this web service, the script send me nothing without error. However, when i test it with postman, the script send me that token.
Here is my PHP script :
//Now create the TOKEN $jwt = JWT::encode( $data, $secret_key, $algorithme ); $unencoded_array = ['jwt' => $jwt, 'admin' => $admin]; //echo "test"; echo json_encode($unencoded_array);
And here is my client call :
$rootScope.Connect = () => { //Set params to request var request = Global.url_api+'action=Connection&username='+$scope.username+ '&password='+$scope.pwd+ '&project='+$rootScope.project; //Ask to the server if credentials is correct $http.get(request) .then((response) => { console.log(response) }
BUT, when i uncomment this
echo "test";
I receive my token with that string as you can see here :
Any idea ? if you need more information, please don't hesitate to ask.
-
How can i get my table values from html to servlet?
I need to get my html table values in my servlet
Hi,
Im doing a project during my acadamic courses about sudoku website.
During my project I have encounterd a problem that I can't slove - get my table html values into my servlet. I have tried doing things like set hidden names and getParameterValues but none of them worked.
this is my html table
<table class="center"> <% int n =9; for(int s = 0; s<n; s++){ %> <tr> <% for(int f=0; f<n; f++) { %> <td><% int z = SF[s][f]; if(z==0) {%> <input type="text"> <% } else { %> <%=SF[s][f]%> <%}%> </td hidden name="z"> <% } %> </tr hidden name="z"> <% } %> </table>
and this is my empty servlet
package View; import org.omg.CORBA.SystemException; 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 java.io.IOException; import java.io.PrintWriter; @WebServlet(name = "CheckSudokuServlet",urlPatterns = "/CheckSudokuServlet") public class CheckSudokuServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); //tried - String td[]=request.getParameterValues("z"); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
-
Spring MVC program to upload and display the uploaded record in jsp page
I am newbie to Spring MVC. I had an immediate task to upload text/csv file and read the records and display in jsp page there itself. I am not getting proper resources to read, Please help me on it finding me the right resource or with your coding Thanks in advance
-
How can I load an URL in DataBase when I have a MultipartFile?
I have to upload an IMG in my form. I setted the file as String so I get an Invalid Format. How can I convert the file to String? Where am I doing wrong?
I'm using mySQL, Servlet, JSP, Spring, Hibernate.
package it.si2001.model; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.Type; import org.hibernate.validator.constraints.NotEmpty; import org.joda.time.LocalDate; import org.springframework.format.annotation.DateTimeFormat; import java.util.HashSet; import java.util.Set; @Entity @Table(name="employee_tab") public class Employee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @Column(name="document_link_str") private String documentLinkStr; @Size(min=2, max=50) @Column(name = "first_name", nullable = false) private String firstName; @Size(min=2, max=50) @Column(name = "last_name", nullable = false) private String lastName; @Size(min=3, max=15) @Column(name = "mobile_no", nullable = false) private String mobileNo; @NotNull @DateTimeFormat(pattern="yyyy-MM-dd") @Column(name = "birth_date", nullable = false) @Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate") private LocalDate birthDate; @NotEmpty @Column(name = "ssn", unique=true, nullable = false) private String ssn; @ManyToOne @JoinColumn(name = "status_id") private Status status; @ManyToMany(cascade = CascadeType.REFRESH,fetch=FetchType.EAGER) @Fetch(FetchMode.SELECT) @JoinTable(name = "emp_emp_skill", joinColumns = { @JoinColumn(name = "employee_id") }, inverseJoinColumns = { @JoinColumn(name = "skill_id") }) private Set<Skill> skills = new HashSet<Skill>(); public int getId() { return id; } public void setId(int id) { this.id = id; } public String getDocumentLinkStr() { return documentLinkStr; } public void setDocumentLinkStr(String documentLinkStr) { this.documentLinkStr = documentLinkStr; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getMobileNo() { return mobileNo; } public void setMobileNo(String mobileNo) { this.mobileNo = mobileNo; } public LocalDate getBirthDate() { return birthDate; } public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; } public String getSsn() { return ssn; } public void setSsn(String ssn) { this.ssn = ssn; } public Status getStatus() { return status; } public void setStatus(Status status) { this.status = status; } public Set<Skill> getSkills() { return skills; } public void setSkills(Set<Skill> skills) { this.skills = skills; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + id; result = prime * result + ((ssn == null) ? 0 : ssn.hashCode()); return result; }//close hashCode @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Employee)) return false; Employee other = (Employee) obj; if (id != other.id) return false; if (ssn == null) { if (other.ssn != null) return false; } else if (!ssn.equals(other.ssn)) return false; return true; }//close equals @Override public String toString() { return "Employee{" + "id=" + id + ", documentLinkStr='" + documentLinkStr + '\'' + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", mobileNo='" + mobileNo + '\'' + ", birthDate=" + birthDate + ", ssn='" + ssn + '\'' + ", status=" + status + ", skills=" + skills + '}'; }//close toString }//close class
This is my Controller:
/*This method will provide the medium to add a new employee.*/ @RequestMapping(value = {"/new"}, method = RequestMethod.GET) public String newEmployee(ModelMap model) { Employee employee = new Employee(); model.addAttribute("employee", employee); model.addAttribute("edit", false); return "registration"; }//close newEmployee /*This method will be called on form submission, handling POST request for saving employee in database. It also validates the user input */ @RequestMapping(value = {"/new"}, method = RequestMethod.POST) public String saveEmployee(@Valid Employee employee, BindingResult result, ModelMap model, FileUpload fileUpload) throws IOException { /* BindingResult contains the outcome of this validation and any error that might have occurred during this validation.*/ if (result.hasErrors()) { return "registration"; } /*Before saving/updating an employee, we are checking if the SSN is unique.If not, we generate validation error and redirect to registration page.*/ if (!employeeService.isEmployeeSsnUnique(employee.getId(), employee.getSsn())) { FieldError ssnError = new FieldError("employee", "ssn", messageSource.getMessage("non.unique.ssn", new String[]{employee.getSsn()}, Locale.getDefault())); result.addError(ssnError); return "registration"; }//close saveEmployee MultipartFile multipartFile = fileUpload.getFile(); //Now do something with file... String UPLOAD_LOCATION = "C:/test/"; FileCopyUtils.copy(fileUpload.getFile().getBytes(), new File(UPLOAD_LOCATION + fileUpload.getFile().getOriginalFilename())); String fileName = multipartFile.getOriginalFilename(); employeeService.saveEmployee(employee); model.addAttribute("documentLinkStr", fileName); System.out.println("TEST filename: " + fileName); model.addAttribute("success", "Employee " + employee.getFirstName() + " registered successfully"); return "success"; }//close saveEmployee
This is my jsp:
<div class="form-container"> <div class="row"> <div class="form-group col-md-12"> <label class="col-md-3 control-lable" for="file">Upload a file</label> <div class="col-md-7"> <form:input type="file" path="file" id="file" class="form-control input-sm"/> <div class="has-error"> <form:errors path="file" class="help-inline"/> </div> </div> </div> </div>
When I run the project and compile the form I get "Invalid Format".