Anil Mundra

Greenhorn
+ Follow
since Nov 14, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Anil Mundra

Hi,

I am building a web service in RAD 7.0. Here when i am testing my web service on UTC than it is successfully running but it is not running on browser and giving the HTTP error 404. After starting the server when I run http://localhost:9080 than also it is giving me HTTP error 404. Is there any configuration required for server. Please help me.

Thanks in advance.
15 years ago
hi

I think it is wait()

the yield is used to restart that one .....
hi,

Your tomcat is already running.

Open task manager and end the tomcat related task.

Cheers
hi to all,

Can anybody tell me about plugin of "VISUAL JSP EDITOR" for Eclipse 3.2

Thanks in advance
hi,
as you wrote..............
I mean to say is in .jsp property name is ssNum where as in SearchForm it is setSsNum().

Here the concept is that the property name which is given in jsp file i.e. ssNum will be autometically retrived in bean class in the variable with same name.

Now I think you are confusing in it:-
In jsp property name ssNum
In Bean class variable name ssNum

Mean both are same

But the standard syntax of getters and setters is
setSsNum and getSsNum
Here we have to use the first letter as capital. So these above two method works for ssNum.

Now I think it is clear to you.........
Cheers
16 years ago
Thank you Andr�.....
16 years ago
Thank you David and Andr�-John Mas for your valuable comments.
But still i am in confusion.
I am a student developer not a professional developer. Now will you please tell me should i continue to learn struts-1 or start to learn struts-2.
Please give me advice.
Again Thank you very much.....
16 years ago
I am new in struts. I have a little experience in it. Should i switch to Struts 2 or not? Is Struts 1 provides base for struts 1?
Please help me...!
Thanks in advance.
16 years ago
hi,
i am uploading a file using jsp, but it is not working can any body help me. The source code for jsp file is:


<%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
<%@ page import="java.io.FileWriter,java.io.IOException" %>
<%
String savePath = "", filepath = "", filename = "";
String contentType = "", fileData = "", strLocalFileName = "";
int startPos = 0, endPos = 0;
int BOF = 0, EOF = 0;
%>
<%!
//copy specified number of bytes from main data buffer to temp data buffer
void copyByte(byte [] fromBytes, byte [] toBytes, int start, int len)
{
for(int i=start;i<(start+len);i++)
{
toBytes[i - start] = fromBytes[i - start];
}
}
%>
<%
contentType = request.getContentType();
out.println("<br>Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
{
DataInputStream in = new DataInputStream(request.getInputStream());
DataInputStream in1 = in;
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength)
{
byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
}
out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);

//String file = new String(dataBytes);
//out.println("<br>File Contents:<br>////////////////////////////////////<br>" + file + "<br>////////////////////////////////<br>");

byte[] line = new byte[128];
if (totalBytesRead < 3)
{
return;//exit if file length is not sufficiently large
}

String boundary = "";
String s = "";
int count = 0;
int pos = 0;

//loop for extracting boundry of file
//could also be extracted from request.getContentType()
do
{
copyByte(dataBytes, line, count ,1);//read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("Content-Disposition: form-data; name=\""); //set the file name
if(pos != -1)
endPos = pos;
}while(pos == -1);
boundary = fileData.substring(startPos, endPos);

//loop for extracting filename
startPos = endPos;
do
{
copyByte(dataBytes, line, count ,1);//read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("filename=\"", startPos); //set the file name
if(pos != -1)
startPos = pos;
}while(pos == -1);
do
{
copyByte(dataBytes, line, count ,1);//read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("Content-Type: ", startPos);
if(pos != -1)
endPos = pos;
}while(pos == -1);
filename = fileData.substring(startPos + 10, endPos - 3);//to eliminate " from start & end
strLocalFileName = filename;
int index = filename.lastIndexOf("\\");
if(index != -1)
filename = filename.substring(index + 1);
else
filename = filename;

//loop for extracting ContentType
boolean blnNewlnFlag = false;
startPos = endPos;//added length of "Content-Type: "
do
{
copyByte(dataBytes, line, count ,1);//read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("\n", startPos);
if(pos != -1)
{
if(blnNewlnFlag == true)
endPos = pos;
else
{
blnNewlnFlag = true;
pos = -1;
}
}
}while(pos == -1);
contentType = fileData.substring(startPos + 14, endPos);

//loop for extracting actual file data (any type of file)
BOF = count + 1;
do
{
copyByte(dataBytes, line, count ,1);//read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf(boundary, startPos);//check for end of file data i.e boundry value
}while(pos == -1);
EOF = count - boundary.length();
//file data extracted

out.println("<br><br>0. Local File Name = " + strLocalFileName);
out.println("<br><br>1. filename = " + filename);
out.println("<br>2. contentType = " + contentType);
out.println("<br>3. startPos = " + BOF);
out.println("<br>4. endPos = " + EOF);
out.println("<br>5. boundary = " + boundary);

//create destination path & save file there
String appPath = application.getRealPath("/");
out.println("<br>appPath : " + appPath);
String destFolder = appPath + "images/banner/";//change this as required
filename= destFolder + filename;
FileOutputStream fileOut = new FileOutputStream(filename);
fileOut.write(dataBytes, BOF, (EOF - BOF));
fileOut.flush();
fileOut.close();
out.println("<br>File saved as >> " + filename);
//file saved at destination
//out.println("<br>File data : <br><br>**************************<br>" + (new String(dataBytes,startPos, (endPos - startPos))) + "<br><br>**************************");
}
else
{
out.println("Error in uploading ");
}

%>


___________________________________________________________________________
The supportive html file is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>



<form method="post" action="fileupload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<tr>
<td align="left"><b>Select a file to upload :</b></td>
</tr>
<tr>
<td align="left">
<input type="file" name="uploadfile" size="50">
</td>
</tr>
<tr>
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
16 years ago
JSP
hi
in my struts application i am using action mapping which code is:

package classes.com.virtualclass.struts;

import org.apache.struts.action.ActionMapping;
public class LoginActionMapping extends ActionMapping {

protected boolean loginrequired = false;

public LoginActionMapping() {
super();
}

public boolean isLoginrequired() {
return loginrequired;
}

public void setLoginrequired(boolean loginrequired) {
this.loginrequired = loginrequired;
}

}

***************the code in web.xml*****************************8
<init-param>
<param-name>mapping</param-name>
<param-value>classes.com.virtualclass.struts.LoginActionMapping</param-value>
</init-param>


***************Tho code in strutsconfig.xml*************************
<action path="/Upload" type="classes.com.virtualclass.struts.UploadAction" name="uploadForm" scope="request" validate="true" input="/Upload.jsp">
<set-property property="loginRequired" value="true" />
<forward name="success" path="/FacultyHome.jsp" />
<forward name="failure" path="/Upload.jsp" />
</action>
***********************************************************************
When i run this application then i get the error that MESSAGE RESOURCE NOT FOUND UNDER MESSAGE RESOURCE KEY

BUT if i remove this line from my strutsconfig.xml
<set-property property="loginRequired" value="true" />
then it is working.

I want that only after login a person can use upload action
Please help me.
Thanks in advance............!
16 years ago
hi
in my struts application i am using action mapping which code is:

package classes.com.virtualclass.struts;

import org.apache.struts.action.ActionMapping;
public class LoginActionMapping extends ActionMapping {

protected boolean loginrequired = false;

public LoginActionMapping() {
super();
}

public boolean isLoginrequired() {
return loginrequired;
}

public void setLoginrequired(boolean loginrequired) {
this.loginrequired = loginrequired;
}

}

***************the code in web.xml*****************************8
<init-param>
<param-name>mapping</param-name>
<param-value>classes.com.virtualclass.struts.LoginActionMapping</param-value>
</init-param>


***************Tho code in strutsconfig.xml*************************
<action path="/Upload" type="classes.com.virtualclass.struts.UploadAction" name="uploadForm" scope="request" validate="true" input="/Upload.jsp">
<set-property property="loginRequired" value="true" />
<forward name="success" path="/FacultyHome.jsp" />
<forward name="failure" path="/Upload.jsp" />
</action>
***********************************************************************
When i run this application then i get the error that MESSAGE RESOURCE NOT FOUND UNDER MESSAGE RESOURCE KEY

BUT if i remove this line from my strutsconfig.xml
<set-property property="loginRequired" value="true" />
then it is working.

I want that only after login a person can use upload action
Please help me.
16 years ago
Thank you very much.
I got it. Actually there was some coding mistake by me. Now it is working.
Thank you again.
16 years ago
thank you for comments.
yes i want to use that errors to display in my form by html:errors tag.
but if the error comes at the bean class then it is displaying the error by that tag but in action class it is not returning to the my form.
16 years ago
Sorry...! I am extremly very sorry for my mistake.
16 years ago
hi,
i think you didn't configure the Eclipse.
First of all open J2EE perspective it will make easy to work.
Just go into windows-> prefences and make some configuration like
set java compiler,
and check automatic build in menu bar -> project->Build Automatically.......
16 years ago