Help coderanch get a
new server
by contributing to the fundraiser

paul sun

Greenhorn
+ Follow
since Dec 22, 2000
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 paul sun

Hi Deepa,
For JobDetail servlet, do (a typical way):
* get job number
String job_Number = request.getParameter("jobNumber");
** get job object
Job job = (Job)DB.getJob(job_Number);
*** bind the job object to request
request.setAttribute("job", job);
**** forward to a jsp displaying the job
For jsp, do:
* jsp gets the job object
<jsp:useBean id="job" class="package.Job" scope="request" />
** jsp get properties from the job object
Title:<%= job.getTitle() %>
Salary:<%= job.getSalary() %>
Term:<%= job.getTerm() %>
...
# Job - a bean representing a single job holding the details
# DB - a bean for database query, or something holding the job info; maybe the data already in the session
Hope useful!
paul sun

Originally posted by Deepa Balasubramanayam:
Hi Paul,
If I code JobDetail servlet to process a single job detail , WHAT I HAVE TO CODE TO GET THE JOB NUMBER WHICH HAS BEEN SELECTED INSIDE THE JOBDETAIL SERVLET.
Thanks
Deepa



23 years ago
The popular model seems MVC.
*Servlet - Mediator or Controller
*Jsp - View or Presentation Template
*Bean - Model or Data Handling, Business logic
For very very simple application, jsp is enough. For some kind of pattern or framework driven application, Consider MVC.
Paul
23 years ago
Thanks Maha
Hava a nice day!
Paul Sun
23 years ago
Hello Deepa,
On the first page listing all searched job, rewrite the job number on the specific job number link. Like following:
<href a="JobDetail?jobNumber=<%= searchedlistbean.getJobNumber(i)" %>" >Job Number:<%= searchedlistbean.getJobNumber(i)" %></a>
* JobDetail is a servlet or jsp to process a single job detail and response a page about a detailed job.
Hope helpful to you.
Paul Sun
23 years ago
Amit, thank you,
When using the jsp file with the repeated <%@include ...%>, it works with my computer; however, when moving the same file to webappcabaret.com, I got the above error. Both run on the Tomcat. I don't know why. Now I remove all the repeated <%@include ...%> in my jsp files to make the codes adaptive to any host.
Maha, thank you,
When I use <jsp:include page="something" flush="true" /> (not repeated) many times in a jsp file, sometimes I get an error "response already committed!". After removing some, better only one left, it runs happy. I read servlet and jsp specs, both say the RequestDispatcher's include and <jsp:include.../> have restriction to be used. . How can we avoid the "IllegalStateException" when dealing with <jsp:include .../>?
Thanks again.

[This message has been edited by paul sun (edited April 01, 2001).]
23 years ago
The sample jsp file like this:
...
<%@ include file="spacer.html" %>
<%@ include file="menu.html" %>
<%@ include file="spacer.html %>
<%@ include file="content.html" %>
...
When running this code, I got an error saying following:
"org.apache.jasper.compiler.ParseException: Seen file /spacer.html already, maybe this is a recursive include?!"
When I remove one of <%@ include file="spacer.html" %>, it runs successfully.
Does it means I can not include two or more same included files?
How should I do if I want to include more than one same file?
Thanks.
23 years ago
Use toArray(Object obj[]) method of Collection framework.
23 years ago
Some already wrote some utils to do this for, eg, www.servlets.com.
23 years ago
Encapsulate a bean with the result into request or session in the servlet, and then the jsp retrieves the result from the bean through the forwarded request or session.
23 years ago

Changed to: <jsp:include page="banner.jsp" flush=="true" />
flush="true" is mandatory for jsp1.1
23 years ago
"package servlets;" ??
23 years ago
Get com.oreilly.servlet package to use multipart classes to serve your need.
23 years ago
Either
"<%@ page import="beans.*" %>
<jsp:useBean id="stringBean" class="stringBean" />
or
<jsp:useBean id="stringBean" class="beans.stringBean" />
is ok.
But "package beans;" must appear in the "stringBean.java" file. If not, the compiled jsp (or servlet) can not find the "stringBean.class" via the class path search.
Compile "stringBean.java" without "package beans;" in the java file, and put the class file in the /web-inf/classes, and then use
<jsp:useBean id="stringBean" class="stringBean" /> without directive. See what you get.

Originally posted by darine darine:
Thnaks for your time,it works the way you said,but it works even without the page directive.
My question is if i do not put " package beans;" in my stringBean.java file,can i use that directive as above"<%@ page import="beans.*" %>
and the i use the action <jsp:useBean id="stringBean" class="stringBean" />
can i do that?
thanks for your time again.



[This message has been edited by paul sun (edited March 09, 2001).]
23 years ago
work directory
Try to do this:

//=================
<%@ page import="beans.*" %>
<jsp:useBean id="stringBean"
class="beans.StringBean" />
<%-- <jsp:getProperty name="stringBean" property="message" /> --%
<jsp:setProperty name="stringBean" property="message" value="hello matt from new directories " />
<jsp:getProperty name="stringBean" property="message" /><br>
//===========================
Here is my bean java file:
//==========================
package beans;
public class StringBean
{
private String message="No message specified ";
public void setMessage(String message)
{
this.message=message;
}
public String getMessage()
{
return this.message;
}
}

[This message has been edited by paul sun (edited March 09, 2001).]
23 years ago
Use a servlet does the authentication. If the user is authenticated, then use dispatcher to forward to http://mycompany.com/download.exe. The user will only see the servlet URL.
Or setup <security-constraint> in web.xml to protect URL. Even if the unauthenticated user knows the URL, he still cannot access the URL.

That's what I think.
23 years ago