Mike Phillip

Ranch Hand
+ Follow
since Dec 05, 2007
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 Mike Phillip

Hi there,

Here is my problem,

I have a servlet that recieves a request but I don't need to send the response back to the user, I need only to print in the console what would be the response, in this case a simple html code.

the thing is, to print this html I'm using something like System.out.ptintln("<html><head><titlte>title</title></head></html">");

it is working fine for what I want, but my html is not that simple, it's a big one and it's very hard to write the html using System.out.println


So I thought using a jsp to generate the code, and then print the result, but I don't know how to use call the jsp without returning the response, like a request dispath forward


I needed something like:

myservlet method {

String htmltoprint = callmyjsp
System.out.print(htmltoprint);


}

how can I call the jsp and print it, without sending back?

thanks
13 years ago
JSP
Hi,

In my app there are more then 3 servlets. And I need to call something like the init() method to config somethings.

But I think the init is only for its servlet, how can I do some init like so that all servlets can use the things I will start in it?

thanks
14 years ago
thanks guys, really helpful
14 years ago
Hi, I trying to do an web app, and I'm having problems with the servlet mapping settings.

I that when the user hits http://localhost:8080/myapp/
it goes do the servlet I mapped, and it will redirect to a jsp file.

So I did:

<servlet>
<servlet-name>Serv1</servlet-name>
<servlet-class>com.myapp.MyIndexServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Serv1</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

it seems to work fine,

but is this the right way to map the first page to and servlet? could I do with a <welcome-file>

And if I have other servlets, and put other mapping, will they be affected by this patter?

thanks
14 years ago
Hi there, I want to show the user's name in the header of my page after the user logs in(like javaranch does: "hello, username".

When the user logs in I do this in the action:
session.setAttribute("user", loginForm.getLogin());


now, how can I show the attribute in the page? I tryed a

#{sessionScope.user}

but didn't work.

thanks
15 years ago
thanks dude, It's working now.

ActionMessages errors = new ActionMessages();
errors.add("userid",new ActionMessage("errors.user.already.exists"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
15 years ago
I'm tryng that. But it doesnt show the error in the page. I do some println to see if the error is added and it prints ok.

but doesn't show the error in the <html:errors/>
15 years ago
thanks for reply.

but that way you showed it redirects to another page.

I would like to know if its possible to show the error in the the same page, like errors that says that a field is required and are show in <html:errors>

thanks
15 years ago
Hi there, I have some questions about the validation process.

I have this form to register a user, and it uses the the client-side validation framework and aldo the validate method of the form form server-side.

My question is, once the form validates that all fields are well formated, where do I do a validation for check if the username is already chosen, in the form or in the action?

if in the form: doesn't this breaks the mvc pattern? the form will know how the logic works

if in the action: how can I report the "login already in use" to the same page that has the form?

thanks
15 years ago
Hi there,

I'm using this code to make a link to an action:



this is working fine

but now I need to open the link for the action in a new window, so a made this javascript function, but I don't know how to pass this action as a parameter to the js function

this is the function:



anyone can help?

thanks
15 years ago
thanks guys, I'll try that.


best regards
15 years ago
Hi there,

I have a form (MyForm) that has a bean (Car). The Action (MyAction) sets the value of the car property.

Then I want to show in the .jsp file the properties inside the Car bean (model, year...)

after the action sets the property the jsp has the following:

<logic resent name="myForm" property="car">
Car model <bean:write name="car" property="model"/><br>
</logic resent>

but it doesn't works, says that the bean car is not present.

When I do

<logic resent name="myForm" property="car">
Car model <bean:write name="myForm" property="car"/><br>
</logic resent>

it prints the car.toString

I need to get the car and then print its properties.

any help?

thanks
15 years ago
Hi there,

I'm sing struts and I need to iterate some object and each object will have a link that pass the id of that object to a action like this:



this works fine, but the parameter to the action is hardcoded, I'd like to get it with

<bean:write name="car" property='<bean:write name="car" property="id"/>'/>


but it doesn't work, how can I pass the id to the parameter?


thanks
15 years ago
thanks dude, I tested with HttpClient and it works!!


words can't say enougth how grateful I am
15 years ago