Showing posts with label Web Application. Show all posts
Showing posts with label Web Application. Show all posts

Tuesday, May 17, 2011

Deployment in WebLogic

Hi people!
It's been a while since I worked with WebLogic (to be specific in 2004-2005), so I forgot some specific tricks that you've to know (now that I rely a lot on my always reliable Maven and STS), but there is one really important: Don't forget to include in your WEB-INF folder your weblogic.xml

I really hate to get married with propietary technologies, my philosophy is simple: (besides "Work Hard, Have Fun") "Use Open Source and Never get married to any vendor" (I usually develop using Tomcat and my target server could be something else - like 90% of my projects - and same thing happens with DB)

Thursday, August 19, 2010

How to test servlet using Telnet

Essentially what I need to do is just make an HTTP Call using Telnet.

$> telnet 127.0.0.1 9086
Ok, I'm connected, and now what??
I know which servlet I want to test, I know which parameters is expecting, then "let's do it":

Which method should I use? POST or GET?? let's use POST (due to well known limitations with GET)

This is my URL:
/MyWebApp/proxyServlet?operation=doSomethingNice&consumerName=myActiveMQConsumers&server=192.168.5.122:9080&targetServlet=/MyOtherWebApp/utilsServlet
I'll finish my command with the HTTP version I want to use: HTTP/1.0 (if I use 1.1 it'll keep you connected)

And finally let's put all together:

Important: Once you have copied this full line in your telnet body, please type ENTER twice.

How do I know if this works? You should see this on your telnet console:
HTTP/1.0 200 OK
Content-Type: text/xml;charset=ISO-8859-1
Cache-Control: no-cache
Content-Language: en-US
Content-Length: 21
Date: Thu, 19 Aug 2010 18:38:45 GMT
Server: WebSphere Application Server/6.1

true

Connection to host lost.

Friday, August 13, 2010

Spring MVC - Binding VO to a Form

Problema:
I have a VO and I wanted to populate it on my JSP and on my controller just process the VO already populated.

Solution:

On my POST method I'll handle my VO already populated.
This entry will do 50% of the job @ModelAttribute(value="LoggerVO") LoggerVO loggerVO
On my JSP I'll map using spring's tag library
By doing this modelAttribute="LoggerVO" commandName="LoggerVO"
I'm matching what I have on my form and what I have on my Controller
I hope this will help you!
Salu2

Monday, August 9, 2010

Adding Spring Web MVC part 2

Now I'll show you a couple of examples how it looks like a Controller & a JSP using Spring MVC.

From my personal perspective Defining a controller gives you a lot of power, because you can define a method to handle RequestMethod.GET, just to show a Form, and another method to handle the RequestMethod.POST to handle the "submit", cool isn't it?

By adding @Controller you already told Spring, "hey this dude is going to be a Controller".

@RequestMapping(value="/configuration/*") means: "If my URL is WebContext/configuration/ this Controller is going to handle the Request"

Then on each method I can define my path below /configuration/ @RequestMapping(value = "showConsumersConfiguration.do"), something like this WebContext/configuration/showConsumersConfiguration.do

I almost forgot @Autowired which is for inject implementation of that Bean


If you want to handle an object like a form (bind an object to a form), check this out

Important, include these tag libraries!

By using this attribute modelAttribute="UserVO" of form:form tag, I'm binding this line of my controller: modelMap.put("UserVO", userVO); with my form

If you see carefully, each attribute of my VO, has a reference on my JSP, at least as hidden field, but all of them are there

Now my form has been binded to my VO @ModelAttribute UserVO paramUserVO

Now you're ready to play around with this thing!!!

Always go to the official documentation to get more details!!!

Adding Spring Web MVC

I'll try to be brief.

Basically, you need to add a new Servlet on you web.xml, a configuration file (let's call it webApplicationContext.xml) and some Annotations.

This is my example:

My web.xml

The framework will, on initialization of a DispatcherServlet, look for a file named [servlet-name]-servlet.xml (webApplicationContext-servlet.xml) in WEB-INF by default, but if you provide parameter "contextConfigLocation" you can define a location and name for your configuration file.

My webApplicationContext.xml

Which basically is divided in 3 sections:

  • We're going to use configuration based onn annotations
  • Location of my Controllers
  • And where are located my JSP's

In my next entry I'll cover how it looks like a Controller & JSP.

Sunday, June 27, 2010

WebServices with CXF - Configuration files - web.xml