This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

nick tomer

Greenhorn
+ Follow
since Oct 18, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by nick tomer

Hi Roel De Nijs

Thanks for your very descriptive answer. I really appreciate it.

I need to get used to the java type of questions which in my opinion are very sneaky.

Now I understand the question !
Hi

I just started reading the book and i am struggling with the following:

In Introduction page XXXVI does the code compiles from question 14 in assessment test?

The code that I see is:




When I try this it doesn't compile but in the answes it says answer DEF.

Please let me know

Thanks

Nick
Hi Maxim

I just got back from my holidays. I ll have a good look at your answer because some concepts are new to me so I will let you know when I got something.

Thanks
Thanks again. I am trying to follow your answer but I need to read some stuff before I get a clear view of your answer.

Let me explain to you what I am really trying to do.

I am working on creating a Rest web service using Apache CXF. The web service does the simple thing of fetching data from a database and presenting them in xml.

In my database I have one table called "servers"

table:servers:
col:vendor
col:ram
col:name

and one table called "locations"

table:locations
col:longitude
col:latitude


So, I have created a POJO for each of these tables as below





So the WS for the servers connects to my DB and fetches a ResultSet of servers. Then I have a class called ResultSetToObjectList<Server> where I pass the ResultSet and it returns me a List<Server> list with all the data of the ResultSet.

Then I just return a Response.status(Status.OK).entity(new GenericEntity<List<Server>>({}).build(); and I get XML back.

Here is how my WS looks like




The problem with my current implementation is that each time that I want to get data from another table of my database then I have to create a new POJO for the new table and create a new WS resource class to deal with my new resource type (e.g. employees).

What I am trying to do is to drive a new WS resource creation with only a configuration file. Lets say that I was to be able to get data from a new table called employees. If the table have two columns only "name" and "surname" then I want to give add the json code below to a config.json file that I have and the Web Service to be able to create automatically the Employee POJO at runtime and according to the request URL to return appropriate data back. For example the localhost:8080/rest/servers/get will return servers' data back and the localhost:8080/rest/employees/get will return employees' data back. But I will not have to write not even one line of code for that. The Web Service will pick up automatically all the required info from the config.json file in order to decide what data to return. And all these has to happen at run time. This is why I wanted to have generics that will be resolved at runtime (something that i was totally wrong :P). Do you have now a more clear view on what I am trying to do?



Thanks for the info Maxim. I did some reading on what you said and I understood what you mean and why my class architecture does not work currently.

Do you have any suggestions on how I could achieve this level of flexibility that I am looking for in runtime? Is Class<?> more close to what I am looking for?

Thanks
Hi everyone

I am looking for a way to instantiate a generic class at runtime with a class which is also created at runtime.

Here is my code overview

I have a config.json file which helps me to build classes with attributes, getters and setters (POJO if this is the correct name to give).

e.g.







When I try to instantiate the MyUtility class with the Class.forName("MyPojo.class") it doesn't like it.
Is there any way to instantiate the MyUtility class at runtime with the MyPojo.class which I also create at runtime?

Thanks
Ok thanks a lot. I'll start experimenting on that.
8 years ago
No. i'd rather to have a web xml but i don't know how. It is weird to me that there is no web.xml but all of my servlets works properly.
I hope to figure it out.
8 years ago
I will take a look the link you sent me.
all my projects in eclipse are web dynamic projects.
in one of my projects i have created 10 servlets that works perfectly but there is no web xml in my whole workspace that maps my servlets.

https://coderanch.com/t/514873/vc/Eclipse-web-xml-servlet-mapping
8 years ago
Honestly i searched in google with the right keywords but there are not many full axamples. the most of them are shoing the code of filter class.
I will study more.

the other thing is tha eclipse does not create a web.xml file so i cannot configure the filter order.
If i am wrong about that let me know.

thanks
8 years ago
I read a little bit about the filters and i have some questions that i couldn't found any answer.

The FilterChain.doFilter(request,response) method is used to invoke the next filter in the chain. How it knows which is the next filter?
Where i am going to write the filter code? Inside the code of servlet A?
The Servlet A calls the filter-> the filter calls Servlet B -> Servlet B returns result to Filter and filter return the results to Servlet A?

Thanks
8 years ago
Sorry for the "it doesn't work".

I solved my first question.

My second question remains.
is there any tool that calculate the time between request and response? I want to compare my code with web services implementation and servlets implementation. Which is more fast, etc?
8 years ago
Hi, I have 2 servlets. Servlet A in computer A and Servlet B in computer B runnng on tomcat 7. In servlet A i have a link <a href="http://computerB:8080/Servlet B">link</a> that calls Servlet B Giving to it some parameters.
Servlet B takes these parameters and creates an xml string.
My first question is how the servlet B will the xml string automaticly back to Servlet A? I tried the response.sendredirect("http://computerA:8080/ServletA") but it doesn't work.
Do you have any idea?

My secod question: is there any tool that calculate the time between request and response? I want to compare web services and servlets. Which is more fast?
8 years ago
I have to make a project for a lesson in my university and i want at the presentation of the project to show to my professor the request/response soap messages that exchanges the client with the web service.
I thought that i could see them at the http request/ response with firefox addons but i was wrong. I will check the TCPMOn or SoapUI.
If you have another way i'll be waiting?

thanks
8 years ago
thanks a lot. I will look up the jax-ws.
8 years ago