hem raj

Greenhorn
+ Follow
since Apr 07, 2010
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by hem raj


Hello Rob,

I have done code for inserting image as per your instruction...


now what to do for retriving image on JSP..

what to write in Action Class to retrive image and On jsp page...??



hey Rob i have one question.....

before doing this i have tried for storing image on local disk....

it is working on my machine perfactly....
but when i am accessing from another machine the image is not coming.... then i got solution like on another machine first i have to access my machine from RUN....then i gave username/password for my machine .

and on my machine i have put folder of image in shared.

then it will allow and work perfactly...

but this solution is not good there for i am moving for storing image in database...

is there any posibility to access image from local disk without accessing (from RUN) my machine from client machine..?

and one thing is that i am working on windows environment... where as my deployment server is linux environment..

i am using jboss-4.0.4RC1 application server..



Now is it Ok??

file=new File("C:/ImageUpload/tra8.jpg");
fis=new FileInputStream(file);
str= "Insert into Image values(?,?)";
pstmt = dbConnection.prepareStatement(str);
pstmt.setInt(1,1);

byte[] b= new byte[fis.available()+1];
fis.read(b);
pstmt.setBytes(2,b);
pstmt.execute();
Many Thank Rob

i have done following code for saving image

FileInputStream fis;
File file;
String str="";

file=new File("C:/Image/tra8.jpg");
fis=new FileInputStream(file);
str= "Insert into Image values(1,'"+(int)file.length()+"')";

db.execute(str);
System.out.println("insert successfully");

the above code is inserting image....i don't know the above code is right or not.. but it insert record in table;

but i am not understanding how to retrive image on JSP..

what to write in Action Class to retrive image and On jsp page...??


hello

i am uploading image from jsp.
can anybody tell me how to store image in oracle database using struts1.2?

as well please tell me how to retrive image from oracle database..?

thanking you
put your text value between single quotes....


eg.. insert into table(fieid) values('some text,text');


can anybody know how to close Birt Report Database connection?
i m using MyEclipse IDE.

thanks in advance....
13 years ago
thnaks...... got solution
13 years ago


hi

can anybody tell me how to connect mysql database with struts 1.2

i have make some code but it give's me error like : connection could not establish....

thanking you

13 years ago

thanks bear....

i want to develop mail server..as well mail client.....

thanks
13 years ago
JSP
hi....


i want to implement mail server.
i want to develop the system using java/jsp/struts/mysql.
can anybody tell me the step to implement mail server..?


thanks

13 years ago
JSP
Please refer this code .......

in js file

var req;
function ajaxFunction(value)
{
//Do the Ajax call
url = "<bean:message key="ohc.homeurl" bundle="alias"/>/action.do?method=fillCombo&deptId="+value;
// alert(url);
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
try {
req.open("POST", url, true); //was get
alert('open')
} catch (e) {
alert("Problem Communicating with Server\n"+e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE

// alert("in I.E");
req = new ActiveXObject("Microsoft.XMLHTTP");
// alert(req);

if (req) {
// alert("in side req");
req.onreadystatechange = populateSecondBox;
req.open("POST", url, true);
req.send();
}
}
}
/* function processMessage() {
alert("function called");
alert("in process "+req.readyState);
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
alert('ready');
alert("Ajax response:"+req.responseText);

document.getElementById("secondBox").innerHTML = req.responseText;


} else {
alert("Problem with server response:\n " + req.responseText);
}

}
}*/
//Callback function
function populateSecondBox()
{
var returnElements;
var flag=0;
document.getElementById('hodBox').options.length = 0;
document.getElementById('secondaryBox').options.length = 0;
var cnt=0;
if (req.readyState == 4)
{ // Complete
if (req.status == 200)
{ // OK response
textToSplit = req.responseText;

if(textToSplit == '803')
{
alert("No select option available on the server")
}
//Split the document
returnElements=textToSplit.split("||")
//Process each of the elements
for ( var i=0; i<returnElements.length-1; i++ )
{
valueLabelPair = returnElements[i].split(";");
if (valueLabelPair[1]!='**' && valueLabelPair[0]!='**')
{
document.getElementById('hodBox').options[i] = new Option(valueLabelPair[1], valueLabelPair[0]);
cnt++;
}
else
break;
}
document.getElementById('secondaryBox').options.length = 0;
var j=0;
for ( var i=cnt+1; i<returnElements.length-1; i++,j++ )
{
valueLabelPair = returnElements[i].split(";");
document.getElementById('secondaryBox').options[j] = new Option(valueLabelPair[1], valueLabelPair[0]);
}
}
}
}


in jsp

<html:select property="deptCode" onchange="ajaxFunction(this.value)" styleId="deptBox">
<option value="" selected="selected" ><bean:message key="label.select"/></option>
<html:optionsCollection name=""
property=""
value="deptCode"
label="deptName"/>

<html:select property="hodEcNo" onchange="setEcNo()" styleId="hodBox">
<html:option value="nothing">--Select Department First -</html:option>

<html:select property="secondaryEcNo" onchange="setEcNo()" styleId="secondaryBox">
<html:option value="nothing">--Select Department First -</html:option>


in Action File


public ActionForward fillCombo(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws SQLException,Exception
{

ResultSet rSet = null;
String deptCode=request.getParameter("deptId");

System.out.println("deptCode : "+deptCode);
DataSource ds = (DataSource)getDataSource(request);
DataBase db = new DataBase();
String combo="select ec_no,initcap(e_name) from emp order by initcap(e_name)";
System.out.println("qry : "+combo);
if(db.connectDB(ds,request))
{
rSet = db.getData(combo);


String outputString="Null;--Select--||";
while(rSet.next())
{


outputString=outputString+rSet.getString(1);
outputString=outputString+";";
outputString=outputString+rSet.getString(2);
if (rSet.next())
{
outputString=outputString+"||";
rSet.previous();
}
else
break;
}
outputString=outputString+"||";
System.out.println("output String 1= " + outputString);
outputString=outputString+"**;**||";
outputString= outputString+"Null;--Select--||";
combo="select ec_no,initcap(e_name) from emp order by initcap(e_name)";
rSet = db.getData(combo);
while(rSet.next())
{
outputString=outputString+rSet.getString(1);
outputString=outputString+";";
outputString=outputString+rSet.getString(2);
if (rSet.next())
{
outputString=outputString+"||";
rSet.previous();
}
else
break;
}
outputString=outputString+"||";

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(outputString);

out.flush();
out.close();


}
return mapping.getInputForward();
}