Wednesday, December 30, 2009

Post Xml data without form in JSP and receive

How to post xml data in JSP page without form field and get it's data
in the next JSP page.

The first file post-data.jsp is just taking xml data form xml file and
sending xml data as a post to the get-post.jsp page.

Find Full Solution Here:
http://agalaxycode.blogspot.in/2014/07/post-xml-data-without-form-in-jsp-and.html


first file is:
post-data.jsp
--------------
< %@ page import="java.net.*" % >
< %@ page import="java.io.*" % >
< %@ page import="java.util.*" % >
< %@ page import="java.text.*" % >
< %
try
{
URL u;
u = new URL("http://localhost:9292/post/get-post.jsp");
// get the xml data from xml file which you want to post
String inputFileName="C:\\temp1.xml";
FileReader filereader =new FileReader(inputFileName);
BufferedReader bufferedreader=new BufferedReader(filereader);
String initial=bufferedreader.readLine();
String finalData=new String();
while(initial!=null)
{
finalData=finalData+initial;
initial=bufferedreader.readLine();
}
String s=(finalData.toString());
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestMethod("POST");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
uc.setAllowUserInteraction(false);
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
dstream.writeBytes(s);
dstream.close();
InputStream in = uc.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
buf.append(line);
}
in.close();
out.println(buf.toString());
}
catch (IOException e)
{
out.println(e.toString());
}
% >


Second file is:
get-post.jsp
-----------------

< %@ page import="java.util.*" % >
< %
String postedData = request.getReader().readLine();
///// perform here your operation for postedData
out.println("Posted Data is ");
out.println(postedData);
% >

Tuesday, December 29, 2009

Post Xml data without form in PHP and receive

How to post Xml data without form in PHP and receive
=====================================================
If it is not working in localhost/localsystem, try to run it in from live server.


here is the first file which will send xml data

vp-post4.php
-------------
< ? php
#get the xml data from xml file which you want to post
$xml = file_get_contents("temp1.xml");
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $xml
)));
// put here host name with page name.
// if it is not working in local try to run it in live server.
$file = file_get_contents("http://localhost:90/post/vp-postget4.php", false, $context);
echo $file;
?>


here is the second file which will receive xml data

vp-postget4.php
-------------------

< ? php
$xml = file_get_contents("php://input");
// perform here your operation for received xml data
/////// .....
/////// .....
echo "received data is : ".$xml;
?>

Wednesday, December 16, 2009

Get current logged user user_id in Social Engine 4

How to get current logged user user_id in Social Engine 4

As you know that Social engine used Zend framework.
In any page if you need current logged in user's user_id then you can find it via this
one piece of line code:

$currentUserID=Engine_Api::_()->user()->getViewer()->getIdentity();
echo $currentUserID;


now current logged in user's id stored in the variable $currentUserID,
you can use it in your code as you want.

Info tab is not working in Social Engine 4

Member Info tab is not working in Social Engine 4


I was working fix bugs in social engine 4. There were lot of bugs, but the one bug was very strange.  When any user logon and see own profile by clicking on “My Profile” link.
A sub menu tab is show with “Updated”, “Notes”, “My Contacts Groups” etc.
The sub menu tab “Updated”, “Notes”, “My Contacts Groups” are working but after the rest all sub tabs for ex: “Info”, “Contacts”, “Albums” and in “More+” dropdown tabs links were  not working.  The same problem was occurring when any logged in user see his/her friend’s or other user’s profile, that’s information were not coming.


Info tab is not working in Social Engine 4
Info tab is not working in Social Engine 4




















I have solved it. If you are facing the same problem then make the listed below changes:

1) Open the file   container-tabs's Controller.php file

2) Goto line number 56 and search the listed below code:
$childrenContent .= $child->render() . PHP_EOL;  

3) Make it comment:
//$childrenContent .= $child->render() . PHP_EOL;

4) and paste listed below code:

 if($child->getIdentity()=="945") {
            $cntDivStart=count(explode("<div", $child->render()))-1;
            $cntDivEnd=count(explode("</div", $child->render()))-1;
            if($cntDivEnd<$cntDivStart) {
                        $childrenContent .= $child->render() ."</div>". PHP_EOL;
            } else  {
                        $childrenContent .= $child->render() . PHP_EOL; 
            }
} else {
            $childrenContent .= $child->render() . PHP_EOL;
}