aspose file tools*
The moose likes Struts and the fly likes Little Bit of Information Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Little Bit of Information" Watch "Little Bit of Information" New topic
Author

Little Bit of Information

Prathik Ashok
Greenhorn

Joined: Mar 27, 2012
Posts: 12
hey guys,

I am new here and i have a project like to develop a website

So far i have created few JSP's and now i need to link one JSP to another i don't know what exactly i should do after creating a JSP i am following the MVC architecture i understand that the JSP is Model and stuff

Like this is what i need it to do like when a user clicks on submit i need the data to go another jsp

Now my questions are after creating the JSP should i create a servlet or is there any other thing that i should create before i create a Servlet ???

I am using Struts and I have a struts.xml and web.xml like suppose i want to map the action in which file should i do it???

Thanks

Prathik
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hello and Welcome to the Ranch :)
It is a good idea to pick a better subject than "jsp" in a forum called "JSP".
(ok, I see you have edited the subject :) Thanks)
Since you mentioned that you are using Struts, then examining a Struts sample project will greatly help you and shed more lights.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I find it is strange to create the view first (JSP page) and then creating a controller (servlet or Struts action). I suggest you follow a Struts tutorial.
Struts framework is well documented and old, you shouldn't have pain looking for online tutorials.
Prathik Ashok
Greenhorn

Joined: Mar 27, 2012
Posts: 12
thank you for your advice i changed the name of the topic :)

The thing is i don't know where to map the action whether i should do it on Struts.xml or web.xml

here is a sample of my Struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />

<package name="default" extends="struts-default" namespace="/">
<action name="login" method="authenticate"
class="job.portal.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
<action name="Register" method="insertInfo"
class="RegAction">
<result name="success">regpage.jsp</result>
<result name="error">regpage.jsp</result>
</action>
<action name="Register" method="resetInfo"
class="RegAction">
<result name="success">regpage.jsp</result>
<result name="error">regpage.jsp</result>
</action>
</package>
</struts>

Like what is happening now is the data I enter on the jsp gets transferred to database and the page just refreshes
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

You have:

Whether it is a "success" or an "error" you are forwarding to the same page, are you setting some scope-hosted variable to indicate the result of you action?
If your question is about Struts, then please let me know. I will move it to our "Struts" forum where you can also get more Struts specific replies.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Removed by me. Unformatted XML caused my an illusion of duplicated entries.
Prathik Ashok
Greenhorn

Joined: Mar 27, 2012
Posts: 12
Well suppose I give the name of the other JSP On Sucess what happens is It inserts the data and then gives me an error saying the resource() cannot be opened

So should i create a servlet so that it can go to the other JSP

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Little Bit of Information