Java EE

17K

Solutions

7

Articles & Videos

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Share tech news, updates, or what's on your mind.

Sign up to Post

Difference Between Path Parameter and query parameter in web service
0
On Demand Webinar - Networking for the Cloud Era
LVL 8
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Hello Sirs,

I have CSRF protection enabled, and CSRF parameters added to my login JSP view.
My question is the following: Should add CSRF parameters to the rest of my JSP view that involve form submission?

I am looking forward to hearing from you.
0
Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
How to visualize call hierarchy in java using a pencil and paper all the way from beginning till end from UI to say model to controllers to dao to db calls etc including which object go in method and where the values changing etc in the new project

Please advise
0
Hi,
I am looking for String Format Method example using various date formats
https://www.javatpoint.com/java-string-format.

I found above link but no example there using the date format though like MMDDYYYY or YYYYMMDD etc to represent date?
please advise
0
HI,
If i have a class anotated with say @Component or @Service annotation...
And i autowire this in two other classes will the class hold the same object  or does spring creates a new instance of class everytime we do autowire ?

Thanks
0
Hi,
I have a class in which i am Autowiring a controller object like this :

@Component
public class Test {

@Autowired
XController xController;


public String method() {
    return xController.method();
}

Are there any issues with this approach as generally i dont see any controller object autowired anywhere..
Thanks
0
Hi,

When i right click on junit test(say ProductWeightTest.java) and run as Junit test from eclipse i keep getting popup with error

error could not create the java virtual machine error a fatal exception has occurred. program will exit



when i run individual test (checkWeightLessthan10Lb) in above test ProductWeightTest.java  i keep getting initialization error in eclipse console.

i tried changing eclise .ini entries but still getting same error. please advise
0
when i run junit test class getting initializationError Runner: Junit 4

not sure why suddenly i am getting that error and how to resolve it.

please advise
0
Hi,

I have a setter method(setBeginDate) that changed by some one from calendar date object to String object.

now i have to change my unit test to reflect that by changing to String.

articleVisibleData.setBeginDate(setDateMonthYear(30, 1, 2015));

How i edit method above so that i get String

earlier method is

            public Calendar setDateMonthYear(int day, int month, int year) {
            Calendar cal = GregorianCalendar.getInstance();
            cal.clear();
            cal.set(Calendar.DAY_OF_MONTH, day);
            cal.set(Calendar.MONTH, month);
            cal.set(Calendar.YEAR, year);
            return cal;
      }

now i am trying like below but wont work


      public String setDateMonthYear(int day, int month, int year) {
            String str="";
            str= str.concatenate(date).concatenate(month).concatenate(year)
            return str;
      }


earlier from test case i used to call like

articleVisibleData.setDate(setDateMonthYear(30, 1, 2015));

please advise
0
What Is Transaction Monitoring and who needs it?
LVL 1
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

HI,
I have a class :
@Service
public class BotMessage {
        private ExecutorService executorService = Executors.newFixedThreadPool(1);
  public void SendMessage(String message) {
        executorService.submit(() -> sendMessage(message));
    }
}

And i have the following code in a differnt class: 
    private ExecutorService executorService = Executors.newFixedThreadPool(10);
    List<User> userList;
for(int i = 0;i<100;i++){
    User user = userList.get(i);
    executorService.submit(new Task(user));
}

Inside Task there is a run function :

run()  {
    
for(int i = 0; i<100;i++){
    botMessage.sendMessage(i.toString());
}

}


Now for each Task.. As the executorService in BotMessage is having a ThreadPool size of 1 .. The messages passed to sendMessage will be queued and will run one after the other... Which is what i want.. The actual scenario is that theses message will be sent to botMessage based on timestamp and so want it to send in the exact order of timestamp therefore the fixedPool of size 1 is required in botMessage.. Otherwise messages may be delivered out of order...


But The issue is this also blocks the other Tasks... Although each user Task runs in a separte thread of its own but internally calls botMessage.sendMessage... So the same queue will contain messages for user1 and user 2,.....

In an ideal case i would only want a queue per user... And not have it mingled like in the above case..
How do i achieve this..
One way i can think of is probably to …
0
HI,
I have the following code : 
The below code is set to execute every 15 minutes.... 
query table for state, date
if(state === completed) {
    update state to pending
    process()
}
Once the process() function is called it internaly invokes ExecutorService.submit(task)..around 100 such tasks in a loop.
What i want to do is after all the threads are processed i want to update the table state and date to completed, now()
There is an issue with it
     What if say for some reason while inside process()  the program crashes... or the system say shutsdown leaving the table state in pending state forever... Now in this case as state will always be pending state... And the code will never get executed again..
     How to avoid this situation...
     Thanks
0
Hi,
There is a function process which does the following
        for(i = 0;i<100;i++){
        executorservice.submit(task);
        }
       once all the threads have finished there tasks i want to update a table.. How do i know if all the threads have finished the tasks...As the process function will comeout once the threads have finished the task. so probably i need to put a listener somewhere.

Thanks

Thanks
0
Hi,

I have a table which stores date and a state = pending or completed

what i want to do is query the table fetch the date and state...
If the state = completed...
    updates the state to pending
    Then call process()  which in turn invokes threads..
     Once the process() is done execution of all threads..
    update the state to completed and date to now()

    This is what i want to achieve...

    There is following issue with it.

 If my code is running on two different servers...They both will query the same table.. and may see the state as completed... And may start the process().... The issue is both will start the process() which is not what i want...
    The two servers are just for redundancy... And at a time only one should be executing the proces...
    How do i achieve this ?

Thanks
0
HI,
In my spring web application there is a class like : 

[code]
@Service
class BotMessage {
    private ExecutorService executorService = Executors.newFixedThreadPool(1);
     public void sendMessage(message) {
     executorService.submit(() -> sendMessage(message));
}
}
[/code]

In another class : 
[code]
@Service
Public class PullService {
    private ExecutorService executorService = Executors.newFixedThreadPool(10);
   public void pull(Date date) {
        List<UserInfo> getAllUsers = userTokenService.getAllUsers();
        getAllUsers.forEach((o) -> {
                        pullGlobalNotification(o, date, accessToken);
                  }
}
}


 private void pullGlobalNotification(UserInfo userInfo, Date date, String accessToken) {
            GitHub gitHub = githubCache.getIfPresent(userInfo.getUserId());
            executorService.submit(notificationTask);
}[/code]

Now this notificationTask has a run function() {
for(int i = 0;i<10;i++)
botMessage.sendMessage(i.toString());
}

What i am wondering is since botMessage.sendMessage uses an executor with size 1.
now at i = 0 sendMessage will internally call  [b]executorService.submit(() -> sendMessage(message));
[/b]
At i = 1... Will the call to [b]executorService.submit(() -> sendMessage(message));[/b] block if the previous call is still running  as the size of executor is 1. Also will it get queued in the executor and the loop will still continue ? What should be the ideal size in this case.. As this function may be …
0
Hi,

I am reading below link on EJB
https://examples.javacodegeeks.com/enterprise-java/ejb3/ejb-tutorial-beginners/

It is less resource intensive as compared to entity beans. Session bean gets destroyed as soon as user session terminates.

i wonder why session bean is less resource intensive compared to entity bean.

The EJB 3.1 specification introduces @Stateless annotation that enables you to easily create stateless session beans. A stateless session bean as per its name does not have any associated client state, but it may preserve its instance state.



what is difference between client state and instance state?

5. Create a sample Session Bean
The EJB 3.1 specification introduces @Stateless annotation that enables you to easily create stateless session beans. A stateless session bean as per its name does not have any associated client state, but it may preserve its instance state. EJB Container normally creates a pool of few stateless bean’s objects and use these objects to process client’s request.
To create the stateless session bean, perform the following steps.
Right-click the EJB module and choose New > Other to open the New File wizard.
Select Session Bean in the Enterprise JavaBeans category. Click Next.

i do not see option like Session Bean as attached .

i do not see below option
Browse Customer entity for the Return Type and add parameter firstName and lastName.
i cannot see Customer being autopopulated?

please advise
sessionBean.PNG
sessionBean2.PNG
0
Hi,
I have around 3-4 Html pages... This is basically a Thymeleaf document in a spring web application...
The only thing that differs in all the three. is the top line... Some dont have any...
Some have a different sentence  and some have a different color in the sentence...
Now i obviously dont want to keep all the 4 html pages.. As this would be a lot of duplicacy...
What are the ways i can handle such a case...
One i can think of is a set of if else statement in the html page... And depending on the parameter being passed choose the approapriate heading...

Is there any alternative better way for the same ?

Thanks
0
HI,
In my java spring application... There are soem files of around 800 lines...
Does that indicate a bad code design.. What are the factors i should consider to shorten the files and split them into two ?
Whats the ideal maximum file length ?

Thanks
0
Hi,
I have a controller with top level line :
@Controller
@RequestMapping("/github")
public class GitHubController {

The file is getting too big... So i am planning to move some RequestMapping functions inside it to another file...
But that file wll also have the same annotation as the above... and will catch all request with /github...
Will it cause any issue.. ?
Is it a good practice to split in such a way ?
Thanks
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi
i am using a private static nested class in a controller..
And using it inside another methods just to deserialize a json object to this class using jackson objectmapper...

since the code would run in a multithreaded environment i am wondering would that be an issue ?
this is the first time i am using private static nested class.
thanks
0
Here but not working correct me pls
Thank you!!!

public static void main(String[] args) {

    int array1[]= {12, 23, -22, 0, 43, 545, -4, -55, 43, 12, 0, -999, -87};

    System.out.println("Array 1 :");

    Arrays.sort(array1);

    for (int positive: array1) {

        if (positive >= -1)
            System.out.println("Positive numbers :" + positive+ "\t");
        }
        System.out.println();
        System.out.println("Array 2 :");

        for (int negative: array1) {
            if (negative >= -1) {

            }else{ System.out.println("Negative numbers :" +negative);
            }

        }
        System.out.println();

        for (int i = 0; i < array1.length -1; i++) {
             if (array1[/i + 1 ] == array1) {
                 System.out.println("Duplicate element found :" + array1);
                 i = i + 1;

             }    
}
}
}




And a ineed this aoutputs


Starter array: 12 23 -22 0 43 545 -4 -55 43 12 0 -999 -87

Positive array: 12 23 0 43 545 43 12 0

Negative array: -22 -4 -55 -999 -87

Duplicate array :12 0 43

Thx!!!
0
Hi,

In active MQ URL i see(once i login as admin and admin and creating TEST.Q1 after downloading from activemq 9.0 from site and running the bat file)
http://localhost:8161/admin/queues.jsp
I see below
Queues
Name  	Number Of Pending Messages  	Number Of Consumers  	Messages Enqueued  	Messages Dequeued  	Views  	Operations  
TEST.Q1	0	1	5	5	Browse Active Consumers
  	Send To Purge Delete

Open in new window


what is meaning of Messages Enqueued and Messages Dequeued?
please advise
0
Friends

In order to capture the logging information of my application to the tables , I am designing three tables as shown in the attached picture.
Table Structure One Abstract Base Class and Two Concrete Classes
LogType ( Table is the Static Table ) which has only two columns and two rows fixed Id = 1 , 2 and Type = Info , Debug

INFOLOG( Table ) and DEBUGLOG Tables will have additional respective information .

My Question is which Inheritance Strategy is best suited for such scenario , I think of Table for Subclass since My super table(Log Type) is constant and wont change . Please put comments with some annotation examples .
My abstract Base class looks like below


@Inheritance(strategy=InheritanceType.JOINED) 
@MappedSuperclass 
public abstract class LogType implements Serializable 
{ 

private static final long serialVersionUID = 1L; 

@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY) 
@Column(name = "LogTypeId", nullable = false, updatable = false) 
private Integer logTypeId; 

@Column(name = "LogTypeName", unique = true, nullable = false, length = 10) 
private String logTypeName; 
}

Open in new window



However I also think that since my base abstract class has only two static values for column LogTypeName i.e Info and Debug

I can get rid of above abstract base class by introducing enum instead of base class as shown below

public enum LogType{
 INFO,
 DEBUG;
 }

Open in new window


Which can represent a column name in my two concrete tables as

@Entity 
public class InfoLog implements Serializable 
{ 

private static final long serialVersionUID = 1L; 

@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY) 
@Column(name = "InfoLogId", nullable = false, updatable = false) 
private Integer infoLogId; 

@Enumerated(EnumType.STRING)
@Column(name="LogType")
private LogType logType;

@Column(name = "LogDesc", nullable = false, updatable = false) 
private String logDesc; 

}

Open in new window


@Entity 
public class DebugLog implements Serializable 
{ 

private static final long serialVersionUID = 1L; 

@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY) 
@Column(name = "DebugLogId", nullable = false, updatable = false) 
private Integer infoLogId; 

@Enumerated(EnumType.STRING)
@Column(name="LogType")
private LogType logType;

@Column(name = "DebugDesc", nullable = false, updatable = false) 
private String debugLogDesc; 

}
 

Open in new window


However my questions are

1.  Should I go for a abstract base class for my LogType and then use Single table per subclass
2. Should I go for a enum instead of abstract base class as shown above and then just dont use any Inheritance .

Please suggest with examples
0
Hello,
I had/have Eclipse Neon 2 installed.  I then "had" to install IntelliJ.  When I installed IntelliJ I gave it a separate workspace path.
I installed IntelliJ because I want to learn it, yet at the moment I need to do my work on Eclipse Neon2.
It appears that Intellij has invaded the workspace of Eclipse Neon2.
I do not want to uninstall IntelliJ.  So what might be an easy fix?
Or do I need to uninstall IntelliJ?
0
I have JSP page and drop down list programatically populated.
Now, under some circumstances that dropdown should be disabled, but user should be still able to see all of it's element, but can't actually select it, something like this: https://jsfiddle.net/nenadbulatovic/6g4pmmpv/1/

Obviously as there is condition I can't just put disable next option.

This is actual part of code (drop down) where I need that.

  <div class="row-fluid">
    <div class="span3">
      <label><%=Constants.REQUIRED%>&nbsp;<c:out value="${requestScope.RESOURCES_MAP.SITE_PARENT}"/>:</label>
        <select class="selectpicker" data-width="100px" id="siteParentNameSelect" style="width:250px;margin-bottom:0px;">
          <option value=''>${requestScope.RESOURCES_MAP[SELECT]}</option>
          <c:forEach var="siteParentName" items="${siteParentNameList}">
            <option value="${(pageContext.request, siteParentName.id)}" ${siteParentName.id == '0' ? 'selected = "selected" ' : ''}> ${siteParentName.name}</option>
          </c:forEach>
        </select>
    </div>
  </div>

Open in new window


I should check if some condition like "enabledFlag" and then if it is true/false enable/disable its elements for selection.
0

Java EE

17K

Solutions

7

Articles & Videos

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Top Experts In
Java EE