Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Little Bit of Information

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Removed by me. Unformatted XML caused my an illusion of duplicated entries.
 
Prathik Ashok
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Acetylsalicylic acid is aspirin. This could be handy too:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic