1 . Integrate TomCat and Node server?

Answer :

For one, you really shouldn't serve angular pages dynamically. Even if you do serve them from node, serve compiled static pages instead of ng serve - for security, performance and other reasons.

With that said, sure you can do this. This depends a little on your setup, but what it comes down to is that you need to proxy all the angular pages to node server. This has not a lot to do with Angular itself.

So, the easiest way to do this is to tell Apache (or nginx or whoever is in front of your Tomcat) to proxy all 404s to the node server. Then node will render angular site, and this in turn will match the url and render the given page, or if not found, render it's own version of 404.

Alternatively, give your apache or whatever, a specific list of URLs (that are already ported) to pass through to node server.

If you don't use Apache, but are serving things out of Tomcat directly (you shouldn't),

Leave a Comment

1 . Apache tomcat <error-page> tag in conf/web.xml not rendering an error page?

Answer :

using error-code instead of exception-type


2 . Passing an ArrayList from Struts1.3 action to appropriate JSP?

Answer :

Remove attribute redirect="true" from the forward config it makes lose of attributes required for jsp redirected.

How can you be assure about action class if it doesn' t make sense to jsp? The values are evaluated by the EL expressions and rendered by Jstl tags, so you have to make sure they are accessible in the scope of jsp. Forwarding to jsp saves the variables to request scope then you can read them in the for each tag.

3 . Could not get values from request.getParameter Java JSP?

Answer :

disabled elements in a form will not be submitted. You may have to use readonly.

4 . I am trying to print result on same page using ajax query in java servlet form [duplicate]?

Answer :

You never actually call the post function with your ajax code or stop the form from loading the register page.

If you called the post function then checked your console you might see something like Uncaught TypeError: document.getElementByName is not a function, because the function is getElementsByName(notice the s) and it returns a list of elements which needs to be taken into account.
Since you're using jQuery you could just use .serialize() on the form to get its field data.


            type: 'post',
            url: 'RegisterServlet.java',
            data: $(this).serialize(),
            success: function (response)
                document.getElementsByName("insert")[0].innerHTML="Form Successfully Registerd";
        return false;

5 . Thymeleaf list within list input?

Answer :

Template: Create unique "modal" for each job. (work-list.html)

<form method="post" action="#" th:action="@{/work-list}" th:object="${workHistoryDetails}">
      <button type="submit" name="addRow" th:text="'Add Row'">Add row</button>
   <tr id='addr_work0' th:each="workRow, rowStat : *{jobs}">
    <td th:text="${rowStat.index + 1}"></td>
      <td><input type="text" 
                placeholder='Company Name'  class="form-control" th:field="*{jobs[__${rowStat.index}__].companyName}"/></td>
      <td><input type="text" 
                placeholder='Company city' class="form-control" th:field="*{jobs[__${rowStat.index}__].city}"/></td>

      <td><button type="button" class="btn btn-primary" data-toggle="modal" th:attr="data-target='#myModal'+${rowStat.index}" >Open modal</button></td>

      <!-- The Modal -->
      <div class="modal fade" th:id="'myModal'+${rowStat.index}">
       <div class="modal-dialog">
        <div class="modal-content">

         <!-- Modal Header -->
         <div class="modal-header">
           <h4 class="modal-title">Modal Heading</h4>
           <button type="button" class="close" data-dismiss="modal">&times;</button>

         <!-- Modal body -->
         <div class="modal-body">
           <input type="text"
                placeholder='Company Name'  class="form-control" th:field="*{jobs[__${rowStat.index}__].workDoneSentences[0]}"/>
           <input type="text" 
                placeholder='Company city' class="form-control" th:field="*{jobs[__${rowStat.index}__].workDoneSentences[1]}"/>

         <!-- Modal footer -->
         <div class="modal-footer">
           <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>

 <input type="submit" name="submit" value="Add" class="btn btn-danger" />


public WorkHistory populateWorkHistories() {
    return this.workHistory.getAllHistoryDetail();

WorkHistoryService workHistory;

public String greeting(final WorkHistory workHistoryDetails) {
    return "work-list";

public String create(final WorkHistory workHistoryDetails) {

   return "work-list";

// for adding new row job to jobs list
@RequestMapping(value="/work-list", params={"addRow"})
public String addRow(final WorkHistory workHistoryDetails, Model model) {

    Jobs jobRow = new Jobs("","",new ArrayList<>());
    model.addAttribute("workHistoryDetails", workHistoryDetails);
    return "work-list";

Service: Just for the sake of testing:

public class WorkHistoryService {

    static WorkHistory workHistoryDetails =new WorkHistory();
        List<String> workDones = new ArrayList<>();
        List<String> workDones1 = new ArrayList<>();
        workDones1.add("description also");

        Jobs job1 = new Jobs("Twitter", "USA",workDones); 
        Jobs job2 = new Jobs("Microsoft", "USA",workDones1);
        List<Jobs> jobList = new ArrayList<>();

    public WorkHistory getAllHistoryDetail(){

        return workHistoryDetails;

    public void setJobs(WorkHistory workHistory){
        List<Jobs> jobs = workHistory.getJobs();
        for (Jobs job : jobs) {

Jobs domain:

public class Jobs {
   private String companyName;
   private String city;
   private List<String> workDoneSentences;
    //default constructor important!   
    public Jobs() {
   //setter getter

I hope it helps you.

6 . Java EE .jsp file can't be accessed through localhost?

Answer :

I had the same issue, it was because of Wildfly 11. I downgraded it to Wildfly 10.1 and it started working!

7 . Pass value Bean to Class then Class to JSP?

Answer :

Set the value in ServletContext in your bean class:

    private ServletContext servletContext;

    private String a;
    public void setA(String a) {
Get this value in JSP using :

String a=(String)getServletContext().getAttribute("a");

8 . Text Area dynamically created and then gone within a second?

Answer :
I have tried your code and discovered that the problem is coming from your form tag if you remove the form tag it will work just fine.

    <div class="container">

       <div class="row">

         <div class="col-name">
          <label for="section">Section</label>

          <div class="col-value">
           <input type="text" id="section">

        <div class="row">

         <div class="col-name">
          <label for="assignmentname">Assignment Name</label>

          <div class="col-value">
           <input type="text" id="assignmentname">

        <div class="row">

         <div class="col-name">
          <label for="questionnumber">Number Of Questions</label>

          <div class="col-value">
           <input type="text" id="question_number" max="10" min="1"/>

          <div class="col-value">
          <button onclick="generate()">Generate Assignment</button>

        <div id="content">



     function generate(){
    var x = document.getElementById("question_number").value;
    var content = document.getElementById("content");
    var pa= new Array();
    var box = new Array();

    var i=0;
        var box =document.createElement("textarea");
        box.style.animation="moveToPos 5s 1";


9 . List not visible on when sent from Spring controller to JSP?

Answer :

<c:if test="${not empty lists}">


<c:if test="${not empty mediaList}">

10 . Problem with while( rs.next()) in jsp?

Answer :

  Well, yeah. It's hard to tell without the indenting, but it looks like all your code paths redirect to another page during the first rs loop. I don't know the particulars of JSP, but it probably stops execution once it sees that redirect.

11 . How to embed jsp coding into javascript method?how to assing javascript variable in jsp session in javascriptm?

Answer :

You might NOT remember, but English language has some grammar rules AND punctuation... Using that helps readers to understand what YOU are trying to say... 

JSP - server side scripting technology, it runs on web server and generates HTML/JavaScript that gets sent to client (browser), ALL generated content gets sent to client (browser) AFTER it FINISHED it's job... 
JavaScript - client side scripting language, it runs on client (browser) AFTER the page is received by the client (browser)... 

The only way to send values from JSP to JavaScript is to generate some JavaScript statements in JSP (assign a JavaScript value...) 
The only way to send values from JavaScript to JSP is to request something from web server (AJAX or simple GET or POST requests)...

12 . How do i implement pop ups using JSP?

Answer :

You r to do it in javascript. If u want to use it in ur JSP page U can use STRUTS tags to include ur javascript code. 
STRUTS has the following tag attributes 

13 . What is Best Web Language for Website designing & as well as CGI Scripting Perl/Java/Php/ HTML/XML/JSP etc ???

Answer :

 You obviously have to use HTML, but as a server side language, I suggest PHP, it is lightweight and you can do nice database stuff with it. 

I am a bit biased as I have not used Perl or JSP, but have used the others, and of which I find PHP works the best. 

But first decide on your needs, and then do research on the benefits of each and choose according to your requirements.

14 . Difference between java script an jsp?

Answer :

 Java is a programming language and it requires compilation before it can be executed where is JSP(Java Server Pages) is server side scripting technology which don't need compilation. t is being interpreted at the runtime!

15 . How to connect jsp with oracle?

Answer :

  It is very easy to connect to oracle database from a JSP though JSP are used to cater the view part of the application. 
You can use classes12.jar file to connect to oracle database. 
put the following code in the scriplet and ensure that you close the connection in the finally block :) 

-Surya Rao.

Source(s)://place the code in the JSP 
//register driver 
//get the database connection 
Connection con = 
DriverManager.getConnection ("jdbc:oracle:thin:@<<DBServerIPaddress>... 
"<<userName>>", "<<password>>"); 
// Create statement 
Statement stmt = con.createStatement (); 
ResultSet rs = stmt.executeQuery ("select * from Emp"); 

// Iterar mientras haya datos. 
while (rset.next ()) 
System.out.println (rset.getString ("empNumber"));