Sunday, August 16, 2009

C++ with netbeans

Few steps should be followed to integrate C++ with netbeans in Windows

1. Download and install MinGW
2. Download and install msys

  • MinGW is the C/C++ compiler
  • Msys is some kind of a unix emulator. After installing it and setting it in the path system variable, you can input unix commands such as mkdir, ls in the dos prompt. This is needed as makefile in C++ needs to access unix commands.

3. In the compile command dialog in netbeans provide the MinGW bin directory for base. Then it will identify C and C++ compilers other than the makefile. You need to provide the makefile.exe in msys/bin as the makefile location.

Then as the K&R said in their famouse C book, "if you have not botched anything, it should work" :-)

Saturday, August 15, 2009

JSP importing class and jar files

Using java class files in jsp files

1. Put the class files in WEB-INF/classes/ folder

2. Import the class as <%@page import="."%>

3. Call that class as you would do in a normal java program

eg:

<%@page import="test.Hello"%>

<%
Hello heloo = new Hello();
String myName = heloo.SayName();
out.println("From scriptlet : "+ myName + "\n");
%>





Using a jar file in jsp

1. Put the jar file in lib folder.

2. Import the jar file as <%@page import=".*"%>

3. Call the class as .

eg:

<%@page import="jarTest.*"%>

<%
jartest.Main m = new jartest.Main();
String name = m.getName("Pinda");
out.println(name);
%>


Monday, August 10, 2009

Vive la Netbeans

Following day's I was completely worries and frustrated with my bad experience on web services with Eclipse plugging for Axis.

Found a solution today. It is netbeans. Really nice and I love the way it creates the implementation from wsdl file.

Saturday, August 8, 2009

axis2 plugins for Eclipse

I wasted a complete day by trying to do a web service using them.

It is a complete bad job. There are no complete set of jar files in lib folder. When the site says it is version 1.4.1 but when downloaded it is shown as 1.3.

Followed 2 tutorials published by WSO2. Oops, only the frustration is left.

When you do something, do it properly.

Tuesday, August 4, 2009

A simple SOAP client

The program is written in C#.

You can find a java client in http://www.cafeconleche.org/books/xmljava/chapters/ch03s05.html

The below code will not work just by copying and executing. If you are familliar with C# will get the idea.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Net;

namespace WWeb
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();

doc.Load(@textBoxIn.Text);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(textBoxURL.Text);

req.Headers.Add("SOAPAction", "\"\"");

req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
WebResponse resp = req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);

richTextBox1.AppendText(r.ReadToEnd());


}

private void buttonIn_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
textBoxIn.Text = openFileDialog1.FileName;
}
}
}

Saturday, August 1, 2009

Creating a table from a query

The method varies according to the DB you are using

Oracle:

create table t_newTable as select * from oldTAble;


mySQL:

create table t_newTable select * from oldTAble;


MSAccess:

SELECT * INTO t_newTable FROM oldTAble;